refactor: 优化ReorganizeDialog组件

为ReorganizeDialog组件进行优化,移除了props中的storage属性,并将其替换为target_storage和target_path属性。同时更新了相关的表单和逻辑处理。
This commit is contained in:
jxxghp
2024-09-20 13:39:33 +08:00
parent 153fe8fcd0
commit aff4b2f9b7
2 changed files with 47 additions and 29 deletions
+47 -28
View File
@@ -13,13 +13,10 @@ const display = useDisplay()
// 输入参数 // 输入参数
const props = defineProps({ const props = defineProps({
storage: {
type: String,
default: () => 'local',
},
logids: Array<number>, logids: Array<number>,
items: Array<FileItem>, items: Array<FileItem>,
target: String, target_storage: String,
target_path: String,
}) })
// 从 provide 中获取全局设置 // 从 provide 中获取全局设置
@@ -39,6 +36,25 @@ const seasonItems = ref(
})), })),
) )
const storageOptions = [
{
title: '本地',
value: 'local',
},
{
title: '阿里云盘',
value: 'alipan',
},
{
title: '115网盘',
value: 'u115',
},
{
title: 'Rclone网盘',
value: 'rclone',
},
]
// 提示框 // 提示框
const $toast = useToast() const $toast = useToast()
@@ -70,13 +86,10 @@ const dialogTitle = computed(() => {
// 表单 // 表单
const transferForm = reactive({ const transferForm = reactive({
storage: props.storage, fileitem: {},
logid: 0, logid: 0,
path: '', target_storage: props.target_storage || 'local',
drive_id: '', target_path: props.target_path ?? '',
fileid: '',
filetype: '',
target: props.target ?? null,
tmdbid: null, tmdbid: null,
doubanid: null, doubanid: null,
season: null, season: null,
@@ -101,8 +114,8 @@ const targetDirectories = computed(() => {
// 监听目的路径变化,自动查询目录的刮削配置 // 监听目的路径变化,自动查询目录的刮削配置
watch(transferForm, async () => { watch(transferForm, async () => {
if (transferForm.target) { if (transferForm.target_path) {
const directory = libraryDirectories.value.find(item => item.library_path === transferForm.target) const directory = libraryDirectories.value.find(item => item.library_path === transferForm.target_path)
if (directory) { if (directory) {
transferForm.scrape = directory.scraping ?? false transferForm.scrape = directory.scraping ?? false
} }
@@ -165,13 +178,10 @@ async function transfer() {
// 整理文件 // 整理文件
async function handleTransfer(item: FileItem) { async function handleTransfer(item: FileItem) {
transferForm.path = item.path transferForm.fileitem = item
transferForm.fileid = item.fileid || '' transferForm.logid = 0
transferForm.drive_id = item.drive_id || ''
transferForm.filetype = item.type || 'dir'
try { try {
const result: { [key: string]: any } = await api.post('transfer/manual', {}, { params: transferForm }) const result: { [key: string]: any } = await api.post('transfer/manual', transferForm)
if (!result.success) $toast.error(`文件 ${item.path} 整理失败:${result.message}`) if (!result.success) $toast.error(`文件 ${item.path} 整理失败:${result.message}`)
} catch (e) { } catch (e) {
console.log(e) console.log(e)
@@ -181,8 +191,9 @@ async function handleTransfer(item: FileItem) {
// 整理日志 // 整理日志
async function handleTransferLog(logid: number) { async function handleTransferLog(logid: number) {
transferForm.logid = logid transferForm.logid = logid
transferForm.fileitem = {}
try { try {
const result: { [key: string]: any } = await api.post('transfer/manual', {}, { params: transferForm }) const result: { [key: string]: any } = await api.post('transfer/manual', transferForm)
if (!result.success) $toast.error(`历史记录 ${logid} 重新整理失败:${result.message}`) if (!result.success) $toast.error(`历史记录 ${logid} 重新整理失败:${result.message}`)
} catch (e) { } catch (e) {
console.log(e) console.log(e)
@@ -214,17 +225,17 @@ onMounted(() => {
<VCardText> <VCardText>
<VForm @submit.prevent="() => {}"> <VForm @submit.prevent="() => {}">
<VRow> <VRow>
<VCol v-if="props.storage == 'local'" cols="12" md="8"> <VCol cols="12" md="6">
<VCombobox <VCombobox
v-model="transferForm.target" v-model="transferForm.target_storage"
:items="targetDirectories" :items="storageOptions"
label="目的路径" label="目的存储"
placeholder="留空自动" placeholder="留空自动"
hint="整理目的路径,留空将自动匹配" hint="整理目的存储"
persistent-hint persistent-hint
/> />
</VCol> </VCol>
<VCol v-if="props.storage == 'local'" cols="12" md="4"> <VCol cols="12" md="6">
<VSelect <VSelect
v-model="transferForm.transfer_type" v-model="transferForm.transfer_type"
label="整理方式" label="整理方式"
@@ -234,13 +245,21 @@ onMounted(() => {
{ title: '复制', value: 'copy' }, { title: '复制', value: 'copy' },
{ title: '硬链接', value: 'link' }, { title: '硬链接', value: 'link' },
{ title: '软链接', value: 'softlink' }, { title: '软链接', value: 'softlink' },
{ title: 'Rclone复制', value: 'rclone_copy' },
{ title: 'Rclone移动', value: 'rclone_move' },
]" ]"
hint="文件操作整理方式" hint="文件操作整理方式"
persistent-hint persistent-hint
/> />
</VCol> </VCol>
<VCol cols="12" md="12">
<VCombobox
v-model="transferForm.target_path"
:items="targetDirectories"
label="目的路径"
placeholder="留空自动"
hint="整理目的路径,留空将自动匹配"
persistent-hint
/>
</VCol>
</VRow> </VRow>
<VRow> <VRow>
<VCol cols="12" md="4"> <VCol cols="12" md="4">
-1
View File
@@ -736,7 +736,6 @@ onMounted(() => {
<ReorganizeDialog <ReorganizeDialog
v-if="transferPopper" v-if="transferPopper"
v-model="transferPopper" v-model="transferPopper"
:storage="inProps.storage"
:items="transferItems" :items="transferItems"
@done="transferDone" @done="transferDone"
@close="transferPopper = false" @close="transferPopper = false"