From 247bfb336e64817e71254b325fa268f0c377a226 Mon Sep 17 00:00:00 2001 From: kyx236 Date: Sun, 1 Feb 2026 07:37:49 +0800 Subject: [PATCH] feat: Implement database-backed configuration management and the main backend application entry point. --- backend/cmd/main.go | 5 +++++ backend/internal/config/config.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/backend/cmd/main.go b/backend/cmd/main.go index 8db06b0..68eabb5 100644 --- a/backend/cmd/main.go +++ b/backend/cmd/main.go @@ -225,6 +225,7 @@ func handleConfig(w http.ResponseWriter, r *http.Request) { "group_ids": config.Global.GroupIDs, "proxy_enabled": config.Global.ProxyEnabled, "default_proxy": config.Global.DefaultProxy, + "team_reg_proxy": config.Global.TeamRegProxy, "proxy_test_status": getProxyTestStatus(), "proxy_test_ip": getProxyTestIP(), "site_name": config.Global.SiteName, @@ -242,6 +243,7 @@ func handleConfig(w http.ResponseWriter, r *http.Request) { GroupIDs []int `json:"group_ids"` ProxyEnabled *bool `json:"proxy_enabled"` DefaultProxy *string `json:"default_proxy"` + TeamRegProxy *string `json:"team_reg_proxy"` SiteName *string `json:"site_name"` } if err := json.NewDecoder(r.Body).Decode(&req); err != nil { @@ -276,6 +278,9 @@ func handleConfig(w http.ResponseWriter, r *http.Request) { database.Instance.SetConfig("proxy_test_ip", "") } } + if req.TeamRegProxy != nil { + config.Global.TeamRegProxy = *req.TeamRegProxy + } if req.SiteName != nil { config.Global.SiteName = *req.SiteName } diff --git a/backend/internal/config/config.go b/backend/internal/config/config.go index 7427ef8..93c8fd7 100644 --- a/backend/internal/config/config.go +++ b/backend/internal/config/config.go @@ -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)