Private
Public Access
1
0

优化:代码质量提升,修复重复逻辑和语法高亮支持

- 简化计算属性,删除重复代码
- 优化文件扩展名获取逻辑
- 新增文件工具函数库 fileHelpers.js
- 增强 CodeEditor 语法高亮(支持 30+ 语言)
- 修复 Office 文档文件服务器访问权限
- 添加特殊文件名支持(Dockerfile、Makefile 等)
This commit is contained in:
2026-01-30 02:24:09 +08:00
parent b849e6cc46
commit eb2cbad17b
15 changed files with 962 additions and 761 deletions

View File

@@ -3,43 +3,24 @@ package common
import (
"os"
"path/filepath"
"runtime"
)
const (
// AppName 应用名称
AppName = "u-desk"
// AppDataDir 应用数据目录名称(带点号,表示隐藏目录)
AppDataDir = ".u-desk"
)
// GetUserDataDir 获取用户数据目录
// 跨平台支持Windows、macOS、Linux
// 所有平台统一使用: ~/.u-desk
func GetUserDataDir() string {
var basePath string
switch runtime.GOOS {
case "windows":
// Windows: %LOCALAPPDATA% 或 %APPDATA%
basePath = os.Getenv("LOCALAPPDATA")
if basePath == "" {
basePath = os.Getenv("APPDATA")
}
case "darwin":
// macOS: ~/Library/Application Support
homeDir, err := os.UserHomeDir()
if err == nil {
basePath = filepath.Join(homeDir, "Library", "Application Support")
}
default:
// Linux: ~/.config
homeDir, err := os.UserHomeDir()
if err == nil {
basePath = filepath.Join(homeDir, ".config")
}
homeDir, err := os.UserHomeDir()
if err != nil {
return "."
}
if basePath == "" {
basePath = "."
}
return filepath.Join(basePath, AppName)
return filepath.Join(homeDir, AppDataDir)
}