修复:常用系统路径获取,支持桌面文档等快捷访问
This commit is contained in:
@@ -192,26 +192,43 @@ const STORAGE_KEYS = {
|
||||
}
|
||||
|
||||
// 常用路径快捷方式
|
||||
const commonPaths = computed(() => {
|
||||
const platform = window.navigator.platform
|
||||
if (platform.includes('Win')) {
|
||||
return [
|
||||
{ name: '桌面', path: `${process.env.USERPROFILE || ''}\\Desktop` },
|
||||
{ name: '文档', path: `${process.env.USERPROFILE || ''}\\Documents` },
|
||||
{ name: '下载', path: `${process.env.USERPROFILE || ''}\\Downloads` },
|
||||
{ name: 'C盘根目录', path: 'C:\\' },
|
||||
{ name: 'D盘根目录', path: 'D:\\' }
|
||||
]
|
||||
} else {
|
||||
return [
|
||||
{ name: '用户主目录', path: '~' },
|
||||
{ name: '桌面', path: '~/Desktop' },
|
||||
{ name: '文档', path: '~/Documents' },
|
||||
{ name: '下载', path: '~/Downloads' },
|
||||
{ name: '根目录', path: '/' }
|
||||
const commonPaths = ref([])
|
||||
const systemPaths = ref({})
|
||||
|
||||
// 加载常用系统路径
|
||||
const loadCommonPaths = async () => {
|
||||
try {
|
||||
const paths = await window.go.main.App.GetCommonPaths()
|
||||
systemPaths.value = paths
|
||||
|
||||
const platform = window.navigator.platform
|
||||
if (platform.includes('Win')) {
|
||||
commonPaths.value = [
|
||||
{ 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 }
|
||||
]
|
||||
} else {
|
||||
commonPaths.value = [
|
||||
{ name: '🖥️ 桌面', path: paths.desktop },
|
||||
{ name: '📁 文档', path: paths.documents },
|
||||
{ name: '📥 下载', path: paths.downloads },
|
||||
{ name: '🏠 主目录', path: paths.home },
|
||||
{ name: '📂 根目录', path: '/' }
|
||||
]
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载常用路径失败:', error)
|
||||
// 降级方案:使用默认路径
|
||||
commonPaths.value = [
|
||||
{ name: '💿 C盘', path: 'C:\\' },
|
||||
{ name: '💿 D盘', path: 'D:\\' }
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 状态
|
||||
const filePath = ref('')
|
||||
@@ -494,6 +511,7 @@ watch(fileList, (newList) => {
|
||||
|
||||
onMounted(() => {
|
||||
loadFromStorage()
|
||||
loadCommonPaths()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user