feat: Implement database-backed configuration management and the main backend application entry point.

This commit is contained in:
2026-02-01 07:37:49 +08:00
parent 28bdc9d509
commit 247bfb336e
2 changed files with 10 additions and 0 deletions

View File

@@ -37,6 +37,7 @@ type Config struct {
// 代理配置 (可实时更新)
ProxyEnabled bool `json:"proxy_enabled"`
DefaultProxy string `json:"default_proxy"`
TeamRegProxy string `json:"team_reg_proxy"` // Team 注册使用的代理
// 自动化配置
AutoPauseOnExpired bool `json:"auto_pause_on_expired"`
@@ -168,6 +169,9 @@ func InitFromDB() *Config {
if v, _ := configDB.GetConfig("default_proxy"); v != "" {
cfg.DefaultProxy = v
}
if v, _ := configDB.GetConfig("team_reg_proxy"); v != "" {
cfg.TeamRegProxy = v
}
if v, _ := configDB.GetConfig("mail_services"); v != "" {
var services []MailServiceConfig
if err := json.Unmarshal([]byte(v), &services); err == nil {
@@ -207,6 +211,7 @@ func SaveToDB() error {
configDB.SetConfig("proxy_enabled", strconv.FormatBool(cfg.ProxyEnabled))
configDB.SetConfig("default_proxy", cfg.DefaultProxy)
configDB.SetConfig("team_reg_proxy", cfg.TeamRegProxy)
if len(cfg.MailServices) > 0 {
data, _ := json.Marshal(cfg.MailServices)