feat:自动识别命名

This commit is contained in:
jxxghp
2024-06-18 13:56:34 +08:00
parent 865d597fe8
commit 997548b7d6
+32 -4
View File
@@ -44,6 +44,9 @@ const $toast = useToast()
// 是否正在加载 // 是否正在加载
const loading = ref(true) const loading = ref(true)
// 重命名loading
const renameLoading = ref(false)
// 识别进度条 // 识别进度条
const progressDialog = ref(false) const progressDialog = ref(false)
@@ -186,6 +189,27 @@ function showRenmae(item: FileItem) {
renamePopper.value = true renamePopper.value = true
} }
// 调用API获取新名称
async function get_recommend_name() {
renameLoading.value = true
try {
const result: { [key: string]: any } = await api.get('transfer/name', {
params: {
path: `${inProps.path}${currentItem.value?.name}`,
filetype: currentItem.value?.type ?? 'file',
},
})
if (result.success && result.data) {
newName.value = result.data.name
} else {
$toast.error(result.message)
}
} catch (error) {
console.error(error)
}
renameLoading.value = false
}
// 重命名 // 重命名
async function rename() { async function rename() {
emit('loading', true) emit('loading', true)
@@ -495,13 +519,17 @@ onMounted(() => {
<!-- 重命名弹窗 --> <!-- 重命名弹窗 -->
<VDialog v-if="renamePopper" v-model="renamePopper" max-width="50rem"> <VDialog v-if="renamePopper" v-model="renamePopper" max-width="50rem">
<VCard title="重命名"> <VCard title="重命名">
<DialogCloseBtn @click="renamePopper = false" />
<VCardText> <VCardText>
<VTextField v-model="newName" label="名称" /> <VTextField v-model="newName" label="名称" :loading="renameLoading" />
</VCardText> </VCardText>
<VCardActions> <VCardActions>
<VBtn depressed @click="renamePopper = false"> 取消 </VBtn> <VBtn color="success" variant="elevated" @click="get_recommend_name" prepend-icon="mdi-magic" class="px-5 me-3">
<VSpacer /> 自动识别名称
<VBtn :disabled="!newName" depressed variant="tonal" @click="rename"> 重命名 </VBtn> </VBtn>
<VBtn :disabled="!newName" variant="elevated" @click="rename" prepend-icon="mdi-check" class="px-5 me-3">
确定
</VBtn>
</VCardActions> </VCardActions>
</VCard> </VCard>
</VDialog> </VDialog>