Private
Public Access
1
0
Files
u-desk/internal/common/path.go
绝尘 b849e6cc46 新增:应用配置管理模块,优化文件系统功能
- 新增 ConfigAPI 和 ConfigService 实现配置管理
- 新增 SettingsPanel 和 UpdateNotification 组件
- 文件系统模块化重构,提升代码质量
- 提取公共函数,优化代码结构
- 版本号更新至 0.2.0
2026-01-28 23:38:23 +08:00

46 lines
854 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package common
import (
"os"
"path/filepath"
"runtime"
)
const (
// AppName 应用名称
AppName = "u-desk"
)
// GetUserDataDir 获取用户数据目录
// 跨平台支持Windows、macOS、Linux
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")
}
}
if basePath == "" {
basePath = "."
}
return filepath.Join(basePath, AppName)
}