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:
@@ -3,14 +3,25 @@ package accountConfigChecker
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/ssdomei232/goodBaby/internal/meta"
|
||||
)
|
||||
|
||||
// AccountValidator 账号验证器接口
|
||||
type AccountValidator interface {
|
||||
// Validate 验证账号配置是否合法
|
||||
Validate(account string) error
|
||||
Validate(config string) error
|
||||
// GetType 获取验证器支持的账号类型
|
||||
GetType() string
|
||||
// Meta 返回给 WebUI 渲染表单用的元数据
|
||||
Meta() meta.AccountMeta
|
||||
}
|
||||
|
||||
// AccountTester 可选接口:支持真实连通性测试的账号类型实现它
|
||||
type AccountTester interface {
|
||||
// Test 使用给定配置访问一次第三方服务,验证凭据是否可用
|
||||
Test(config string) error
|
||||
}
|
||||
|
||||
// ValidatorRegistry 验证器注册表
|
||||
@@ -51,11 +62,66 @@ func (vr *ValidatorRegistry) Validate(accountType string, config string) error {
|
||||
return validator.Validate(config)
|
||||
}
|
||||
|
||||
// Test 对账号配置做一次真实的连通性测试
|
||||
func (vr *ValidatorRegistry) Test(accountType string, config string) error {
|
||||
validator, exists := vr.validators[accountType]
|
||||
if !exists {
|
||||
return fmt.Errorf("不支持的账号类型: %s", accountType)
|
||||
}
|
||||
|
||||
if err := vr.Validate(accountType, config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tester, ok := validator.(AccountTester)
|
||||
if !ok {
|
||||
return fmt.Errorf("账号类型 %s 暂不支持连通性测试", accountType)
|
||||
}
|
||||
return tester.Test(config)
|
||||
}
|
||||
|
||||
// GetSupportedTypes 获取所有支持的账号类型
|
||||
func (vr *ValidatorRegistry) GetSupportedTypes() []string {
|
||||
types := make([]string, 0, len(vr.validators))
|
||||
for t := range vr.validators {
|
||||
types = append(types, t)
|
||||
}
|
||||
sort.Strings(types)
|
||||
return types
|
||||
}
|
||||
|
||||
// Metas 返回所有账号类型的元数据,按类型名排序
|
||||
func (vr *ValidatorRegistry) Metas() []meta.AccountMeta {
|
||||
metas := make([]meta.AccountMeta, 0, len(vr.validators))
|
||||
for _, v := range vr.validators {
|
||||
metas = append(metas, withTestable(v))
|
||||
}
|
||||
sort.Slice(metas, func(i, j int) bool { return metas[i].Type < metas[j].Type })
|
||||
return metas
|
||||
}
|
||||
|
||||
// MetaOf 返回指定账号类型的元数据
|
||||
func (vr *ValidatorRegistry) MetaOf(accountType string) (meta.AccountMeta, bool) {
|
||||
v, ok := vr.validators[accountType]
|
||||
if !ok {
|
||||
return meta.AccountMeta{}, false
|
||||
}
|
||||
return withTestable(v), true
|
||||
}
|
||||
|
||||
// FieldsOf 返回指定账号类型的字段描述,类型不存在时返回 nil
|
||||
func (vr *ValidatorRegistry) FieldsOf(accountType string) []meta.Field {
|
||||
m, ok := vr.MetaOf(accountType)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return m.Fields
|
||||
}
|
||||
|
||||
func withTestable(v AccountValidator) meta.AccountMeta {
|
||||
m := v.Meta()
|
||||
if _, ok := v.(AccountTester); ok {
|
||||
m.Testable = true
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
@@ -1,20 +1,31 @@
|
||||
package accountConfigChecker
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/ssdomei232/goodBaby/drivers/bilibili"
|
||||
"github.com/ssdomei232/goodBaby/drivers/email"
|
||||
"github.com/ssdomei232/goodBaby/drivers/github"
|
||||
"github.com/ssdomei232/goodBaby/drivers/onebot"
|
||||
)
|
||||
|
||||
var (
|
||||
once sync.Once
|
||||
registry *ValidatorRegistry
|
||||
)
|
||||
|
||||
// InitValidatorRegistry 返回全局唯一的账号验证器注册表
|
||||
func InitValidatorRegistry() *ValidatorRegistry {
|
||||
registry := NewValidatorRegistry()
|
||||
once.Do(func() {
|
||||
r := NewValidatorRegistry()
|
||||
|
||||
// 注册所有账号验证器
|
||||
registry.Register(&bilibili.BilibiliAccountConfigValidator{})
|
||||
registry.Register(&email.EmailAccountConfigValidator{})
|
||||
registry.Register(&github.GitHubAccountConfigValidator{})
|
||||
registry.Register(&onebot.OneBotAccountConfigValidator{})
|
||||
// 注册所有账号验证器
|
||||
r.Register(&bilibili.BilibiliAccountConfigValidator{})
|
||||
r.Register(&email.EmailAccountConfigValidator{})
|
||||
r.Register(&github.GitHubAccountConfigValidator{})
|
||||
r.Register(&onebot.OneBotAccountConfigValidator{})
|
||||
|
||||
registry = r
|
||||
})
|
||||
return registry
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user