feat: additional style system setting (#444)

* feat: additional style system setting

* feat: remove editor font setting
This commit is contained in:
boojack
2022-11-11 23:42:44 +08:00
committed by GitHub
parent 67691d1e99
commit a142d975d7
13 changed files with 72 additions and 78 deletions

View File

@@ -10,15 +10,16 @@ type SystemSettingName string
const (
// SystemSettingAllowSignUpName is the key type of allow signup setting.
SystemSettingAllowSignUpName SystemSettingName = "allowSignUp"
SystemSettingPlaceholderName SystemSettingName = "placeholder"
// SystemSettingAdditionalStyleName is the key type of additional style.
SystemSettingAdditionalStyleName SystemSettingName = "additionalStyle"
)
func (key SystemSettingName) String() string {
switch key {
case SystemSettingAllowSignUpName:
return "allowSignUp"
case SystemSettingPlaceholderName:
return "placeholder"
case SystemSettingAdditionalStyleName:
return "additionalStyle"
}
return ""
}
@@ -58,6 +59,12 @@ func (upsert SystemSettingUpsert) Validate() error {
if invalid {
return fmt.Errorf("invalid system setting allow signup value")
}
} else if upsert.Name == SystemSettingAdditionalStyleName {
value := ""
err := json.Unmarshal([]byte(upsert.Value), &value)
if err != nil {
return fmt.Errorf("failed to unmarshal system setting additional style value")
}
} else {
return fmt.Errorf("invalid system setting name")
}