迁移到 mygo 单进程架构并接入签名自更新

- 单进程:托盘常驻 + 原生设置窗口(internal/settings),移除 Wails 前端与 IPC
- 触发器(鼠标角落 / 边缘滚轮 / 热键)+ 规则引擎 + 动作注册表
- 调节提示条:截屏 + glass.Blur 三层毛玻璃、背景跟随屏幕变化、悬停光感与拖动
- 音量 Core Audio COM、亮度 DDC/CI(gamma 兜底)、多显示器求平均
- 配置热重载 + 版本迁移 v1→v5、便携模式、崩溃取证三件套
- updater/native 插件 + 托盘「检查更新…」,watchdog 识别更新重启
- 自建 Gitea 发布:scripts/publish-gitea.ps1(updates.url 指向 latest Release)
This commit is contained in:
zerorigin committed 2026-11-16 10:31:44 +08:00
1 parent 814012ec52
commit 0b8b9b0775
202 files changed
+7254 -13572

No files matched your search

+36 -3
View File
@@ -28,6 +28,10 @@ const (
targetName = "ZerOriginTool.exe"
checkEvery = 2 * time.Second
snapshotLog = "watchdog.log"
// relaunchGap 是子进程退出后等待新实例出现的时间窗口。mygo 更新器装完更新
// 用 Relaunch 启动新版本:新进程不写 clean-quit 标记,也不是本进程 cmd.Wait
// 捕获的那个 pid,只能靠"同名进程是否又出现"来识别,避免把更新重启当崩溃。
relaunchGap = 1500 * time.Millisecond
)
var (
@@ -62,9 +66,9 @@ type filetime struct {
}
const (
th32csSnapProcess = 0x00000002
processQueryInfo = 0x1000 // PROCESS_QUERY_LIMITED_INFORMATION
epochDelta = 116444736000000000
th32csSnapProcess = 0x00000002
processQueryInfo = 0x1000 // PROCESS_QUERY_LIMITED_INFORMATION
epochDelta = 116444736000000000
errorAlreadyExists = 183
createNoWindow = 0x08000000 // CREATE_NO_WINDOW
)
@@ -269,6 +273,12 @@ func runSupervisor(logDir, logPath, appFlag string) {
watcherLog(logPath, fmt.Sprintf("[%s] supervisor: 检测到正常退出标记,监督进程退出\n", nowStamp()))
return
}
// 更新重启:装配完更新后新实例往往在几百毫秒内就起来了,
// 这时再拉起一个只会被单实例锁挡回来,还留下无用的崩溃快照。
if waitForRelaunch(appBase, relaunchGap) {
watcherLog(logPath, fmt.Sprintf("[%s] supervisor: 检测到 %s 新实例(更新重启),继续被动监视\n", nowStamp(), appBase))
continue
}
logSuspectSnapshot(logPath, nowStamp())
}
@@ -321,6 +331,14 @@ func runSupervisor(logDir, logPath, appFlag string) {
return
}
// 4.5) 更新重启:mygo 更新器装完更新会用 Relaunch 启动新版本,
// 新进程既不写 clean-quit 标记,也不是本进程捕获的 pid。
// 同名进程已经起来 → 不是崩溃,别抓快照也别重复拉起。
if waitForRelaunch(appBase, relaunchGap) {
watcherLog(logPath, fmt.Sprintf("[%s] supervisor: 检测到 %s 新实例(更新重启),转为被动监视\n", nowStamp(), appBase))
continue
}
// 5) 异常死亡:抓快照后自动重启。短命崩溃(<30s)退避到 10s,防重启风暴。
logSuspectSnapshot(logPath, nowStamp())
delay := 3 * time.Second
@@ -338,6 +356,21 @@ func runSupervisor(logDir, logPath, appFlag string) {
}
}
// waitForRelaunch 在目标进程退出后短暂等待同名进程重新出现,
// 用于区分"更新安装后的自动重启"与"崩溃退出"。
func waitForRelaunch(appBase string, gap time.Duration) bool {
deadline := time.Now().Add(gap)
for {
if len(listProcesses()[appBase]) > 0 {
return true
}
if !time.Now().Before(deadline) {
return false
}
time.Sleep(100 * time.Millisecond)
}
}
func flagExists(path string) bool {
_, err := os.Stat(path)
return err == nil