feat: Implement database-backed configuration management and the main backend application entry point.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user