迁移到 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
@@ -4,14 +4,14 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
pwin "zerorigin/internal/platform/windows"
|
||||
"github.com/egoist/mygo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
Register("show_notification", func() Action { return ¬ificationAction{} })
|
||||
}
|
||||
|
||||
// notificationAction 显示系统托盘气泡通知。
|
||||
// notificationAction 显示系统桌面通知。
|
||||
type notificationAction struct{}
|
||||
|
||||
func (a *notificationAction) ID() string { return "show_notification" }
|
||||
@@ -19,8 +19,8 @@ func (a *notificationAction) Name() string { return "显示通知" }
|
||||
|
||||
func (a *notificationAction) Schema() ActionSchema {
|
||||
return ActionSchema{Params: []ParamSpec{
|
||||
{Name: "title", Type: "string", Required: true},
|
||||
{Name: "text", Type: "string", Required: true},
|
||||
{Name: "title", Label: "标题", Type: "string", Required: true},
|
||||
{Name: "text", Label: "内容", Type: "string", Required: true},
|
||||
}}
|
||||
}
|
||||
|
||||
@@ -35,5 +35,26 @@ func (a *notificationAction) Validate(params map[string]any) error {
|
||||
}
|
||||
|
||||
func (a *notificationAction) Execute(ctx context.Context, params map[string]any) error {
|
||||
return pwin.ShowBalloon(GetString(params, "title"), GetString(params, "text"))
|
||||
if !NotificationsAllowed(ctx) {
|
||||
logger.Debug("show_notification suppressed by notify switch", "action", a.ID())
|
||||
return nil
|
||||
}
|
||||
if err := notifyDesktop(GetString(params, "title"), GetString(params, "text")); err != nil {
|
||||
return fmt.Errorf("show_notification: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// notifyDesktop 通过 mygo 通知后端显示一条桌面通知。
|
||||
// mygo 通知后端要求应用已启动:测试环境或启动早期调用时返回错误而不是 panic。
|
||||
func notifyDesktop(title, body string) (err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
err = fmt.Errorf("notification backend unavailable: %v", r)
|
||||
}
|
||||
}()
|
||||
if !mygo.NotificationsSupported() {
|
||||
return fmt.Errorf("当前环境不支持桌面通知")
|
||||
}
|
||||
return mygo.NewNotification(mygo.NotificationOptions{Title: title, Body: body}).Show()
|
||||
}
|
||||
Reference in new issue
Block a user