mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-08-25 01:59:35 +08:00
fix 文件管理路径
This commit is contained in:
@@ -36,17 +36,38 @@ const path: Ref<string | undefined> = ref()
|
|||||||
// 下载目录列表
|
// 下载目录列表
|
||||||
const downloadDirectories = ref<MediaDirectory[]>([])
|
const downloadDirectories = ref<MediaDirectory[]>([])
|
||||||
|
|
||||||
|
// 计算公共路径
|
||||||
|
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('/', '\\')
|
||||||
|
}
|
||||||
|
if (!commonPath.endsWith('/')) {
|
||||||
|
commonPath += '/'
|
||||||
|
}
|
||||||
|
return commonPath.length > 0 ? commonPath : paths[0][0] === '/' ? '/' : ''
|
||||||
|
}
|
||||||
|
|
||||||
// 查询下载目录
|
// 查询下载目录
|
||||||
async function loadDownloadDirectories() {
|
async function loadDownloadDirectories() {
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.get('system/setting/DownloadDirectories')
|
const result: { [key: string]: any } = await api.get('system/setting/DownloadDirectories')
|
||||||
if (result.success && result.data?.value) {
|
if (result.success && result.data?.value) {
|
||||||
downloadDirectories.value = result.data.value
|
downloadDirectories.value = result.data.value
|
||||||
if (downloadDirectories.value.length > 0) {
|
path.value = findCommonPath(downloadDirectories.value.map(item => item.path) as string[])
|
||||||
path.value = downloadDirectories.value[downloadDirectories.value.length - 1].path
|
|
||||||
} else {
|
|
||||||
path.value = '/'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
|
|||||||
Reference in New Issue
Block a user