Refactor code structure for improved readability and maintainability

This commit is contained in:
MengMengCode
2026-06-09 15:33:17 +08:00
parent cf00d0d03d
commit e971d99070
17 changed files with 2068 additions and 178 deletions
+18
View File
@@ -243,6 +243,7 @@ type ClicdConfig struct {
EnabledImages []string `json:"enabled_images"`
Snapshots []Snapshot `json:"snapshots"`
SecurityAutoShutdown bool `json:"security_auto_shutdown"`
Language string `json:"language"`
SSL SSLConfig `json:"ssl"`
SSLCertificates map[string]SSLConfig `json:"ssl_certificates"`
}
@@ -454,12 +455,29 @@ func normalizeConfigDefaults(dataDir string) bool {
AppConfig.EnabledImages = make([]string, 0)
changed = true
}
if AppConfig.Language == "" {
AppConfig.Language = "zh"
changed = true
}
if AppConfig.Language != "zh" && AppConfig.Language != "en" {
AppConfig.Language = "zh"
changed = true
}
if normalizeSSLDefaults() {
changed = true
}
return changed
}
func NormalizeLanguage(language string) string {
switch strings.ToLower(strings.TrimSpace(language)) {
case "en", "en-us", "en_us", "english":
return "en"
default:
return "zh"
}
}
func normalizeSSLDefaults() bool {
changed := false
previousMode := AppConfig.SSL.Mode