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
This commit is contained in:
zerorigin2019 committed 2026-08-05 00:42:45 +08:00
commit 0a1c1e82ea
188 files changed
+19926

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
package action
import (
"context"
"fmt"
"time"
)
func init() {
Register("delay", func() Action { return &delayAction{} })
}
// delayAction 延迟指定毫秒数(响应 context 取消)。
type delayAction struct{}
func (a *delayAction) ID() string { return "delay" }
func (a *delayAction) Name() string { return "延迟" }
func (a *delayAction) Schema() ActionSchema {
return ActionSchema{Params: []ParamSpec{
{Name: "ms", Type: "int", Required: true},
}}
}
func (a *delayAction) Validate(params map[string]any) error {
if ms := GetInt(params, "ms"); ms < 0 {
return fmt.Errorf("delay: ms must be >= 0")
}
return nil
}
func (a *delayAction) Execute(ctx context.Context, params map[string]any) error {
ms := GetInt(params, "ms")
timer := time.NewTimer(time.Duration(ms) * time.Millisecond)
defer timer.Stop()
select {
case <-ctx.Done():
return ctx.Err()
case <-timer.C:
return nil
}
}