Files
zerorigin-toolbox/internal/action/notify.go
T
zerorigin2019 0a1c1e82ea chore: 初始化仓库(零源工具箱 0.1.0 基线)
- Go 主进程 cmd/zerorigin(托盘常驻 + 触发器/规则/动作引擎)
- Wails v3 设置进程 cmd/settings(独立 module)
- 监督进程 cmd/watchdog(-supervise 异常重启)
- 构建脚本 build.bat / NSIS 安装包 deploy/、便携版 portable/
- 架构与 MVP 计划文档 docs/、阶段 0-4 验收记录 deploy/acceptance-0-4.md
2026-08-05 00:42:45 +08:00

40 lines
1.1 KiB
Go

package action
import (
"context"
"fmt"
pwin "zerorigin/internal/platform/windows"
)
func init() {
Register("show_notification", func() Action { return &notificationAction{} })
}
// notificationAction 显示系统托盘气泡通知。
type notificationAction struct{}
func (a *notificationAction) ID() string { return "show_notification" }
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},
}}
}
func (a *notificationAction) Validate(params map[string]any) error {
if GetString(params, "title") == "" {
return fmt.Errorf("show_notification: missing param \"title\"")
}
if GetString(params, "text") == "" {
return fmt.Errorf("show_notification: missing param \"text\"")
}
return nil
}
func (a *notificationAction) Execute(ctx context.Context, params map[string]any) error {
return pwin.ShowBalloon(GetString(params, "title"), GetString(params, "text"))
}