chore: settings util

This commit is contained in:
Noah Hsu
2022-06-27 17:25:19 +08:00
parent 005ded41c3
commit f01a81ee9c
6 changed files with 127 additions and 105 deletions

View File

@ -0,0 +1,22 @@
package setting
import (
"github.com/alist-org/alist/v3/internal/db"
"strconv"
)
func GetByKey(key string) string {
return db.GetSettingsMap()[key]
}
func GetIntSetting(key string, defaultVal int) int {
i, err := strconv.Atoi(GetByKey(key))
if err != nil {
return defaultVal
}
return i
}
func IsTrue(key string) bool {
return GetByKey(key) == "true" || GetByKey(key) == "1"
}