迁移到 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:
1 parent
814012ec52
commit
0b8b9b0775
202 files changed
+7254
-13572
No files matched your search
@@ -0,0 +1,58 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestMigrateV3ToV4EnablesRuleNotify 验证升级到 v4 后每条规则默认开启通知,
|
||||
// 避免旧配置缺字段导致规则通知被零值静音。
|
||||
func TestMigrateV3ToV4EnablesRuleNotify(t *testing.T) {
|
||||
p := tmpConfig(t, `{"version":3,"global":{"enabled":true,"notify":false,"theme":"system","log_level":"info"},"rules":[
|
||||
{"id":"a","name":"A","enabled":true,"notify":false,"priority":10,"trigger":{"type":"mouse_corner","params":{"corner":"top_left","threshold_px":4}},"actions":[{"type":"volume_up","params":{"steps":1}}]},
|
||||
{"id":"b","name":"B","enabled":false,"priority":20,"trigger":{"type":"mouse_corner","params":{"corner":"bottom_right","threshold_px":4}},"actions":[{"type":"volume_down","params":{"steps":1}}]}
|
||||
]}`)
|
||||
cfg, err := loadAt(p)
|
||||
if err != nil {
|
||||
t.Fatalf("load: %v", err)
|
||||
}
|
||||
if cfg.Version != CurrentVersion {
|
||||
t.Fatalf("version = %d, want %d", cfg.Version, CurrentVersion)
|
||||
}
|
||||
if cfg.Global.Notify {
|
||||
t.Fatal("global.notify=false should be preserved")
|
||||
}
|
||||
if len(cfg.Rules) != 2 {
|
||||
t.Fatalf("rules = %d, want 2", len(cfg.Rules))
|
||||
}
|
||||
for i := range cfg.Rules {
|
||||
if !cfg.Rules[i].Notify {
|
||||
t.Fatalf("rule %q notify should default to true", cfg.Rules[i].ID)
|
||||
}
|
||||
}
|
||||
data, _ := os.ReadFile(p)
|
||||
var saved Config
|
||||
if err := json.Unmarshal(data, &saved); err != nil {
|
||||
t.Fatalf("saved json: %v", err)
|
||||
}
|
||||
if saved.Version != CurrentVersion || !saved.Rules[0].Notify || !saved.Rules[1].Notify {
|
||||
t.Fatalf("migrated config not persisted: %s", data)
|
||||
}
|
||||
if !strings.Contains(string(data), `"notify": true`) {
|
||||
t.Fatalf("rule notify missing from migrated json: %s", data)
|
||||
}
|
||||
}
|
||||
|
||||
// TestV4RuleNotifyFalsePreserved 验证已经显式关闭的规则通知不会被迁移重新打开。
|
||||
func TestV4RuleNotifyFalsePreserved(t *testing.T) {
|
||||
p := tmpConfig(t, `{"version":4,"rules":[{"id":"quiet","name":"静默","enabled":true,"notify":false,"priority":10,"trigger":{"type":"mouse_corner","params":{"corner":"top_left","threshold_px":4}},"actions":[{"type":"volume_up","params":{"steps":1}}]}]}`)
|
||||
cfg, err := loadAt(p)
|
||||
if err != nil {
|
||||
t.Fatalf("load: %v", err)
|
||||
}
|
||||
if cfg.Rules[0].Notify {
|
||||
t.Fatal("explicit rule notify=false should be preserved")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user