迁移到 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

+43 -6
View File
@@ -4,11 +4,35 @@ import (
"fmt"
"runtime"
"sync"
"sync/atomic"
"time"
pwin "zerorigin/internal/platform/windows"
)
// toastEnabled 为全局通知总开关(配置 global.notify,默认开启)。
// 所有右下角系统 Toast(自动调节提示与显式的 show_notification)都受它
// 控制;屏幕底部的调节提示条(internal/osd)不受影响。
var toastEnabled atomic.Bool
func init() { toastEnabled.Store(true) }
// SetToastEnabled 设置是否允许自动调节类 Toast。
// 关闭时立即取消尚未显示的待发通知,避免"关掉后还弹最后一个"。
func SetToastEnabled(on bool) {
toastEnabled.Store(on)
if on {
return
}
toastMu.Lock()
if toastTimer != nil {
toastTimer.Stop()
toastTimer = nil
}
toastNext = nil
toastMu.Unlock()
}
// 音量 Toast 去抖实现:快速连按时合并为最后一次显示,
// 避免 Win11 系统 OSD 数字太小/消失太快时 Toast 弹窗闪烁。
//
@@ -30,8 +54,8 @@ const (
volumeToastMuteTitle = "静音"
)
// showBalloonFunc 底层系统通知函数(变量便于测试注入替换)。
var showBalloonFunc = pwin.ShowBalloon
// notifyFunc 底层系统通知函数(变量便于测试注入替换)。
var notifyFunc = notifyDesktop
// toastContent 待显示的 Toast 内容。
type toastContent struct {
@@ -48,7 +72,15 @@ var (
// notifyVolume 在音量/静音动作成功后显示系统 Toast(默认 500ms 去抖合并)。
// level: 调节后的音量百分比(仅 up/down 使用;静音动作传 0,文本不依赖 level)。
// kind: up | down | mute | unmute | mute_unknown。
//
// 保留 allowed=true 的便捷入口给测试与内部默认路径;动作实现应调用
// notifyVolumeAllowed,把规则级开关明确带进来。
func notifyVolume(level int, kind string) {
notifyVolumeAllowed(level, kind, true)
}
// notifyVolumeAllowed 按规则级通知开关显示音量/静音 Toast。
func notifyVolumeAllowed(level int, kind string, allowed bool) {
var title, text string
switch kind {
case "up", "down":
@@ -60,11 +92,16 @@ func notifyVolume(level int, kind string) {
default:
title, text = volumeToastMuteTitle, "静音已切换"
}
scheduleToast(title, text)
scheduleToast(title, text, allowed)
}
// scheduleToast 去抖调度:窗口内多次调用只显示最后一次内容。
func scheduleToast(title, text string) {
// allowed 是调用方在异步路径启动前捕获的规则级开关;全局开关关闭时
// 同样直接忽略,不创建计时器。
func scheduleToast(title, text string, allowed bool) {
if !allowed || !toastEnabled.Load() {
return
}
toastMu.Lock()
defer toastMu.Unlock()
@@ -90,10 +127,10 @@ func flushToast() {
toastNext = nil
toastMu.Unlock()
if next == nil {
if next == nil || !toastEnabled.Load() {
return
}
if err := showBalloonFunc(next.title, next.text); err != nil {
if err := notifyFunc(next.title, next.text); err != nil {
logger.Warn("volume toast failed", "err", err)
}
}