- 单进程:托盘常驻 + 原生设置窗口(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)
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package action
|
|
|
|
import "context"
|
|
|
|
// ruleNotifyKey 是规则级"是否显示通知"开关在 context 中的键。
|
|
//
|
|
// 规则引擎在派发动作前把当前规则的 notify 写入 context:动作实现不
|
|
// 直接依赖 config.Rule,异步路径(音量媒体键读回、亮度合并队列)也能
|
|
// 在启动 goroutine 前捕获该值,避免 context 取消后读不到。
|
|
type ruleNotifyKey struct{}
|
|
|
|
// WithRuleNotify 把规则级通知开关写入 context。
|
|
func WithRuleNotify(ctx context.Context, notify bool) context.Context {
|
|
return context.WithValue(ctx, ruleNotifyKey{}, notify)
|
|
}
|
|
|
|
// RuleNotify 读取规则级通知开关;未设置时默认允许通知。
|
|
func RuleNotify(ctx context.Context) bool {
|
|
if ctx == nil {
|
|
return true
|
|
}
|
|
if v, ok := ctx.Value(ruleNotifyKey{}).(bool); ok {
|
|
return v
|
|
}
|
|
return true
|
|
}
|
|
|
|
// NotificationsAllowed 返回当前动作是否允许弹桌面通知:
|
|
// 全局总开关(global.notify)与规则级开关同时开启才允许。
|
|
//
|
|
// 调节提示条(internal/osd)不经过这里,始终显示;这里只控制右下角
|
|
// 系统 Toast,包括自动调节通知和显式的 show_notification 动作。
|
|
func NotificationsAllowed(ctx context.Context) bool {
|
|
return toastEnabled.Load() && RuleNotify(ctx)
|
|
}
|