mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 15:36:49 +08:00
feat:文件管理批量重命名
This commit is contained in:
@@ -74,6 +74,9 @@ const transferPopper = ref(false)
|
|||||||
// 新名称
|
// 新名称
|
||||||
const newName = ref('')
|
const newName = ref('')
|
||||||
|
|
||||||
|
// 处理目录内所有文件
|
||||||
|
const renameAll = ref(false)
|
||||||
|
|
||||||
// 当前名称
|
// 当前名称
|
||||||
const currentItem = ref<FileItem>()
|
const currentItem = ref<FileItem>()
|
||||||
|
|
||||||
@@ -186,6 +189,7 @@ function getImgLink(path: string) {
|
|||||||
function showRenmae(item: FileItem) {
|
function showRenmae(item: FileItem) {
|
||||||
currentItem.value = item
|
currentItem.value = item
|
||||||
newName.value = item.name
|
newName.value = item.name
|
||||||
|
renameAll.value = false
|
||||||
renamePopper.value = true
|
renamePopper.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,26 +217,44 @@ async function get_recommend_name() {
|
|||||||
// 重命名
|
// 重命名
|
||||||
async function rename() {
|
async function rename() {
|
||||||
emit('loading', true)
|
emit('loading', true)
|
||||||
const url = inProps.endpoints?.rename.url
|
|
||||||
|
let url = inProps.endpoints?.rename.url
|
||||||
.replace(/{storage}/g, inProps.storage)
|
.replace(/{storage}/g, inProps.storage)
|
||||||
.replace(/{path}/g, encodeURIComponent(currentItem.value?.path || ''))
|
.replace(/{path}/g, encodeURIComponent(currentItem.value?.path || ''))
|
||||||
.replace(/{fileid}/g, currentItem.value?.fileid || '')
|
.replace(/{fileid}/g, currentItem.value?.fileid || '')
|
||||||
.replace(/{newname}/g, encodeURIComponent(newName.value))
|
.replace(/{newname}/g, encodeURIComponent(newName.value))
|
||||||
.replace(/{filetype}/g, currentItem.value?.type || 'file')
|
.replace(/{filetype}/g, currentItem.value?.type || 'file')
|
||||||
|
|
||||||
|
if (renameAll.value) {
|
||||||
|
url += '&recursive=true'
|
||||||
|
}
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
url,
|
url,
|
||||||
method: inProps.endpoints?.mkdir.method || 'post',
|
method: inProps.endpoints?.mkdir.method || 'post',
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调API
|
// 关闭弹窗
|
||||||
await inProps.axios?.request(config)
|
|
||||||
|
|
||||||
renamePopper.value = false
|
renamePopper.value = false
|
||||||
newName.value = ''
|
newName.value = ''
|
||||||
emit('loading', false)
|
renameAll.value = false
|
||||||
|
|
||||||
|
// 显示进度条
|
||||||
|
progressDialog.value = true
|
||||||
|
progressText.value = `正在重命名 ${currentItem.value?.path} ...`
|
||||||
|
progressValue.value = 0
|
||||||
|
|
||||||
|
// 调API
|
||||||
|
const result: { [key: string]: any } = await inProps.axios?.request(config)
|
||||||
|
if (!result.success) {
|
||||||
|
$toast.error(result.message)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关闭进度条
|
||||||
|
progressDialog.value = false
|
||||||
|
|
||||||
// 通知重新加载
|
// 通知重新加载
|
||||||
|
emit('loading', false)
|
||||||
emit('renamed')
|
emit('renamed')
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -520,8 +542,16 @@ 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" />
|
<DialogCloseBtn @click="renamePopper = false" />
|
||||||
|
<VDivider />
|
||||||
<VCardText>
|
<VCardText>
|
||||||
<VTextField v-model="newName" label="新名称" :loading="renameLoading" />
|
<VRow>
|
||||||
|
<VCol cols="12">
|
||||||
|
<VTextField v-model="newName" label="新名称" :loading="renameLoading" />
|
||||||
|
</VCol>
|
||||||
|
<VCol cols="6" v-if="currentItem && currentItem.type == 'dir'">
|
||||||
|
<VSwitch v-model="renameAll" label="自动重命名目录内所有媒体文件" />
|
||||||
|
</VCol>
|
||||||
|
</VRow>
|
||||||
</VCardText>
|
</VCardText>
|
||||||
<VCardActions>
|
<VCardActions>
|
||||||
<VBtn color="success" variant="elevated" @click="get_recommend_name" prepend-icon="mdi-magic" class="px-5 me-3">
|
<VBtn color="success" variant="elevated" @click="get_recommend_name" prepend-icon="mdi-magic" class="px-5 me-3">
|
||||||
|
|||||||
Reference in New Issue
Block a user