重构: 活动热切换并发安全 + 代码清理优化
- 活动切换并发安全:App/Scheduler 增加 client/cfg 读写锁与快照访问, 支持运行中热替换客户端,切换活动不再静默覆盖用户自定义 timeApiUrl - 启动失败时写入崩溃日志文件便于事后排查 - 前端类型声明从 Wails 自动生成的绑定派生,避免手写契约漂移 - 提取 parseAccountFile 消除 ExportAccounts/OrganizeAccounts 重复解析逻辑 - 删除 utils 中未使用的 ReadJSON/WriteJSON/WriteError 及空目录 internal/app - gofmt 统一格式化(activity/types/scheduler 字段对齐) - 新增 logger/seckill/utils 单元测试 - 清理 git 中遗留产物(frontend/app.js、yml.txt、其他日志/)并补全 .gitignore
This commit is contained in:
@@ -2,6 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/wailsapp/wails/v2"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
@@ -30,6 +33,13 @@ func main() {
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
println("Error:", err.Error())
|
||||
log.Printf("启动失败: %v", err)
|
||||
// GUI 应用无控制台,把启动错误写入崩溃日志文件,便于用户事后排查。
|
||||
if dir, derr := os.UserCacheDir(); derr == nil {
|
||||
path := filepath.Join(dir, "douyu-go", "startup_error.log")
|
||||
_ = os.MkdirAll(filepath.Dir(path), 0o755)
|
||||
_ = os.WriteFile(path, []byte("斗鱼抢购系统启动失败:\n"+err.Error()+"\n"), 0o644)
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user