This commit is contained in:
2026-05-28 14:47:59 +08:00
parent 957a594a0f
commit 75bd5d726e
+4 -3
View File
@@ -87,12 +87,13 @@ func defaultConfig() *Config {
// configPath 返回当前平台的配置文件路径
func configPath() string {
if runtime.GOOS == "windows" {
// Windows: 相对于可执行文件的 conf/config.toml
exePath, err := os.Executable()
// Windows: 相对于工作目录的 conf/config.toml
// 注意: 使用工作目录而非 os.Executable(),因为 go run 时 exe 在临时目录
wd, err := os.Getwd()
if err != nil {
return "conf/config.toml"
}
return filepath.Join(filepath.Dir(exePath), "conf", "config.toml")
return filepath.Join(wd, "conf", "config.toml")
}
// Linux: FHS 标准 /etc/portal_page/config.toml
return "/etc/portal_page/config.toml"