feat: 完善后端并新增 Vue3 WebUI
后端: - 修复登录校验、DB 并发(单例+WAL+纯Go sqlite)、会话密钥持久化等核心缺陷 - 新增 Timer CRUD/签到/手动触发、执行日志、仪表盘、驱动元数据等 API - 统一驱动接口: 带 context 的执行器、真实错误返回、敏感字段掩码、连通性测试 - 补全钉钉执行器; Timer 触发/提醒去重; 配置支持默认值与环境变量覆盖 前端: - Vite+Vue3+TS+Pinia+Element Plus, 由驱动元数据动态渲染配置表单 - 登录/仪表盘(倒计时环)/定时器/规则/账号/日志/设置页面, 支持暗色模式 - 主题色 #66ccff, 信号波纹 logo, go:embed 单二进制部署 构建: Dockerfile 增加前端构建阶段; 补充各驱动配置文档 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+25
-14
@@ -1,9 +1,13 @@
|
||||
package runner
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
"github.com/ssdomei232/goodBaby/drivers/bilibili"
|
||||
"github.com/ssdomei232/goodBaby/drivers/dingtalk"
|
||||
"github.com/ssdomei232/goodBaby/drivers/email"
|
||||
"github.com/ssdomei232/goodBaby/drivers/github"
|
||||
"github.com/ssdomei232/goodBaby/drivers/onebot"
|
||||
@@ -12,8 +16,8 @@ import (
|
||||
|
||||
// RuleExecutor 规则执行器接口
|
||||
type RuleExecutor interface {
|
||||
// Execute 执行规则
|
||||
Execute(rule *model.Rule) error
|
||||
// Execute 执行规则,ctx 决定了重试的最长时间
|
||||
Execute(ctx context.Context, rule *model.Rule) error
|
||||
// GetType 获取执行器支持的规则类型
|
||||
GetType() string
|
||||
}
|
||||
@@ -36,13 +40,13 @@ func (er *ExecutorRegistry) Register(executor RuleExecutor) {
|
||||
}
|
||||
|
||||
// Execute 根据规则类型执行规则
|
||||
func (er *ExecutorRegistry) Execute(rule *model.Rule) error {
|
||||
func (er *ExecutorRegistry) Execute(ctx context.Context, rule *model.Rule) error {
|
||||
executor, exists := er.executors[rule.Type]
|
||||
if !exists {
|
||||
return fmt.Errorf("不支持的规则类型: %s", rule.Type)
|
||||
}
|
||||
|
||||
return executor.Execute(rule)
|
||||
return executor.Execute(ctx, rule)
|
||||
}
|
||||
|
||||
// GetSupportedTypes 获取所有支持的规则类型
|
||||
@@ -51,24 +55,31 @@ func (er *ExecutorRegistry) GetSupportedTypes() []string {
|
||||
for t := range er.executors {
|
||||
types = append(types, t)
|
||||
}
|
||||
sort.Strings(types)
|
||||
return types
|
||||
}
|
||||
|
||||
var globalExecutorRegistry *ExecutorRegistry
|
||||
var (
|
||||
registryOnce sync.Once
|
||||
globalExecutorRegistry *ExecutorRegistry
|
||||
)
|
||||
|
||||
// InitExecutorRegistry 初始化执行器注册表并注册所有执行器
|
||||
func InitExecutorRegistry() *ExecutorRegistry {
|
||||
registry := NewExecutorRegistry()
|
||||
registryOnce.Do(func() {
|
||||
registry := NewExecutorRegistry()
|
||||
|
||||
// 注册所有规则执行器
|
||||
registry.Register(&bilibili.BilibiliDynamicExecutor{})
|
||||
registry.Register(&email.EmailExecutor{})
|
||||
registry.Register(&github.GithubMakeRepoPublicExecutor{})
|
||||
registry.Register(&onebot.OneBotExecutor{})
|
||||
// 未来添加新规则类型时,在这里注册即可
|
||||
// 注册所有规则执行器
|
||||
registry.Register(&bilibili.BilibiliDynamicExecutor{})
|
||||
registry.Register(&email.EmailExecutor{})
|
||||
registry.Register(&github.GithubMakeRepoPublicExecutor{})
|
||||
registry.Register(&onebot.OneBotExecutor{})
|
||||
registry.Register(&dingtalk.DingTalkExecutor{})
|
||||
// 未来添加新规则类型时,在这里注册即可
|
||||
|
||||
globalExecutorRegistry = registry
|
||||
return registry
|
||||
globalExecutorRegistry = registry
|
||||
})
|
||||
return globalExecutorRegistry
|
||||
}
|
||||
|
||||
// GetGlobalExecutorRegistry 获取全局执行器注册表
|
||||
|
||||
Reference in New Issue
Block a user