From b22ac27075c73ba189136f03c61c6e314f82772e Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sun, 26 May 2024 17:55:38 +0800 Subject: [PATCH] fix --- src/views/reorganize/FileBrowserView.vue | 28 +++++------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/src/views/reorganize/FileBrowserView.vue b/src/views/reorganize/FileBrowserView.vue index e3b1b3d7..8f2add83 100644 --- a/src/views/reorganize/FileBrowserView.vue +++ b/src/views/reorganize/FileBrowserView.vue @@ -36,35 +36,17 @@ const path: Ref = ref() // 下载目录列表 const downloadDirectories = ref([]) -// 计算公共路径 -function findCommonPath(paths: string[]): string { - if (!paths || paths.length === 0) return '' - if (paths.length === 1) return paths[0] - const normalizedPaths = paths.map(path => path.replace(/\\/g, '/')) - const splitPaths = normalizedPaths.map(path => path.split('/')) - let commonParts: string[] = [] - for (let i = 0; i < splitPaths[0].length; i++) { - const part = splitPaths[0][i] - if (splitPaths.every(pathParts => pathParts[i] === part)) { - commonParts.push(part) - } else { - break - } - } - let commonPath = commonParts.join('/') - if (commonPath.includes(':')) { - commonPath = commonPath.replace('/', '\\') - } - return commonPath.length > 0 ? commonPath : paths[0][0] === '/' ? '/' : '' -} - // 查询下载目录 async function loadDownloadDirectories() { try { const result: { [key: string]: any } = await api.get('system/setting/DownloadDirectories') if (result.success && result.data?.value) { downloadDirectories.value = result.data.value - path.value = findCommonPath(downloadDirectories.value.map(item => item.path) as string[]) + if (downloadDirectories.value.length > 0) { + path.value = downloadDirectories.value[downloadDirectories.value.length - 1].path + } else { + path.value = '/' + } } } catch (error) { console.log(error)