diff --git a/common/constants.go b/common/constants.go index 70589041..a9f8a2d5 100644 --- a/common/constants.go +++ b/common/constants.go @@ -100,7 +100,11 @@ var RelayTimeout = GetOrDefault("RELAY_TIMEOUT", 0) // unit is second var GeminiSafetySetting = GetOrDefaultString("GEMINI_SAFETY_SETTING", "BLOCK_NONE") -var Theme = GetOrDefaultString("THEME", "default") +var Theme = "default" +var ValidThemes = map[string]bool{ + "default": true, + "berry": true, +} const ( RequestIdKey = "X-Oneapi-Request-Id" diff --git a/controller/option.go b/controller/option.go index bbf83578..3b1cbad2 100644 --- a/controller/option.go +++ b/controller/option.go @@ -42,6 +42,14 @@ func UpdateOption(c *gin.Context) { return } switch option.Key { + case "Theme": + if !common.ValidThemes[option.Value] { + c.JSON(http.StatusOK, gin.H{ + "success": false, + "message": "无效的主题", + }) + return + } case "GitHubOAuthEnabled": if option.Value == "true" && common.GitHubClientId == "" { c.JSON(http.StatusOK, gin.H{