chore: add theme validation
This commit is contained in:
parent
37afb313b5
commit
bdd4be562d
@ -100,7 +100,11 @@ var RelayTimeout = GetOrDefault("RELAY_TIMEOUT", 0) // unit is second
|
|||||||
|
|
||||||
var GeminiSafetySetting = GetOrDefaultString("GEMINI_SAFETY_SETTING", "BLOCK_NONE")
|
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 (
|
const (
|
||||||
RequestIdKey = "X-Oneapi-Request-Id"
|
RequestIdKey = "X-Oneapi-Request-Id"
|
||||||
|
@ -42,6 +42,14 @@ func UpdateOption(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch option.Key {
|
switch option.Key {
|
||||||
|
case "Theme":
|
||||||
|
if !common.ValidThemes[option.Value] {
|
||||||
|
c.JSON(http.StatusOK, gin.H{
|
||||||
|
"success": false,
|
||||||
|
"message": "无效的主题",
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
case "GitHubOAuthEnabled":
|
case "GitHubOAuthEnabled":
|
||||||
if option.Value == "true" && common.GitHubClientId == "" {
|
if option.Value == "true" && common.GitHubClientId == "" {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
|
Loading…
Reference in New Issue
Block a user