Files
zerorigin-toolbox/internal/action/delay.go
T
zerorigin 0b8b9b0775 迁移到 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)
2026-11-16 10:31:44 +08:00

44 lines
997 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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", Label: "延迟(毫秒)", Type: "int", Required: true,
Help: "动作链中等待的毫秒数(>=0)"},
}}
}
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
}
}