Private
Public Access
1
0

优化:动态获取系统所有盘符(C/D/E/F等)

This commit is contained in:
2026-01-26 02:18:33 +08:00
parent 84ebc1226b
commit 307e0d987d
2 changed files with 57 additions and 10 deletions

View File

@@ -203,14 +203,36 @@ const loadCommonPaths = async () => {
const platform = window.navigator.platform
if (platform.includes('Win')) {
commonPaths.value = [
// 基础路径
const pathList = [
{ name: '🖥️ 桌面', path: paths.desktop },
{ name: '📁 文档', path: paths.documents },
{ name: '📥 下载', path: paths.downloads },
{ name: '💾 用户目录', path: paths.home },
{ name: '💿 C盘', path: paths.root_c },
{ name: '💿 D盘', path: paths.root_d }
{ name: '💾 用户目录', path: paths.home }
]
// 动态添加所有盘符(按字母顺序)
const drives = []
for (const key in paths) {
if (key.startsWith('root_')) {
const driveLetter = key.substring(5)
drives.push({
letter: driveLetter,
path: paths[key]
})
}
}
drives.sort((a, b) => a.letter.localeCompare(b.letter))
// 添加盘符到路径列表
drives.forEach(drive => {
pathList.push({
name: `💿 ${drive.letter}`,
path: drive.path
})
})
commonPaths.value = pathList
} else {
commonPaths.value = [
{ name: '🖥️ 桌面', path: paths.desktop },