迁移到 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 -9
View File
@@ -2,6 +2,7 @@ package action
import (
"context"
"errors"
"fmt"
"sync"
"time"
@@ -18,10 +19,18 @@ func init() {
// switchDesktopShared 为共享的切换桌面动作实例。
var switchDesktopShared = &switchDesktopAction{}
// 切换实现变量化,便于单测注入 fake(生产路径仍为平台层函数)。
var (
switchDesktopCOM = pwin.SwitchDesktopCOM
switchDesktopViaTaskView = pwin.SwitchDesktopViaTaskView
virtualDesktopCount = pwin.VirtualDesktopCount
)
// switchDesktopAction 切换虚拟桌面。
// mode: alternate(往返)/ left / right。
// method: com(默认,COM 直调,无快捷键依赖)/ taskview(Win+Tab 导航)/ hotkey(Win+Ctrl+方向键,
// 仅当系统快捷键未被占用时可用)。com 失败时自动回退 taskview。
// 仅当系统快捷键未被占用时可用)。com 普通失败时回退 taskview;单桌面时直接报错,
// 避免任务视图停留前台后被全屏检测误判。
type switchDesktopAction struct {
mu sync.Mutex
next int32 // alternate 模式下上次切换方向,用于往返
@@ -32,9 +41,16 @@ func (a *switchDesktopAction) Name() string { return "切换虚拟桌面" }
func (a *switchDesktopAction) Schema() ActionSchema {
return ActionSchema{Params: []ParamSpec{
{Name: "mode", Type: "string", Required: true, Default: "alternate"},
{Name: "method", Type: "string", Required: false, Default: "com"},
{Name: "taskview_delay_ms", Type: "int", Required: false, Default: 400},
{Name: "mode", Label: "切换方向", Type: "select", Required: true, Default: "alternate",
Options: []string{"alternate", "left", "right"},
Labels: []string{"交替往返", "上一个桌面", "下一个桌面"},
Help: "alternate:左右交替往返;left/right:固定方向"},
{Name: "method", Label: "切换方式", Type: "select", Required: false, Default: "com",
Options: []string{"com", "taskview", "hotkey"},
Labels: []string{"COM 直调(推荐)", "任务视图导航", "Win+Ctrl+方向键"},
Help: "com:COM 直调(推荐);taskview:Win+Tab 导航;hotkey:Win+Ctrl+方向键"},
{Name: "taskview_delay_ms", Label: "Task View 等待(ms)", Type: "int", Required: false, Default: 400,
Help: "taskview 方式下等待切换动画的毫秒数;<=0 按 400ms"},
}}
}
@@ -74,15 +90,26 @@ func (a *switchDesktopAction) Execute(ctx context.Context, params map[string]any
a.next = -dir
a.mu.Unlock()
}
switch GetString(params, "method") {
method := GetString(params, "method")
delay := time.Duration(GetInt(params, "taskview_delay_ms")) * time.Millisecond
// 单桌面时 taskview / hotkey 都无法切换;任务视图还会停留在前台,
// 被全屏检测误判后抑制全部规则,因此提前返回明确错误。
if method == "taskview" || method == "hotkey" {
if n, err := virtualDesktopCount(); err == nil && n < 2 {
return fmt.Errorf("%w (found %d)", pwin.ErrNotEnoughDesktops, n)
}
}
switch method {
case "hotkey":
return pwin.SwitchVirtualDesktop(dir)
case "taskview":
return pwin.SwitchDesktopViaTaskView(dir, time.Duration(GetInt(params, "taskview_delay_ms"))*time.Millisecond)
default: // com:COM 直调,失败回退 taskview
if err := pwin.SwitchDesktopCOM(dir); err == nil {
return switchDesktopViaTaskView(dir, delay)
default: // com:COM 直调;仅非单桌面错误才回退 taskview
if err := switchDesktopCOM(dir); err == nil {
return nil
} else if errors.Is(err, pwin.ErrNotEnoughDesktops) {
return err
}
return pwin.SwitchDesktopViaTaskView(dir, time.Duration(GetInt(params, "taskview_delay_ms"))*time.Millisecond)
return switchDesktopViaTaskView(dir, delay)
}
}