chore: optimize get settings
This commit is contained in:
@ -71,10 +71,10 @@ func initialSettings() {
|
||||
{Key: conf.ApiUrl, Value: "", Type: conf.TypeString, Group: model.SITE},
|
||||
{Key: conf.BasePath, Value: "", Type: conf.TypeString, Group: model.SITE},
|
||||
{Key: conf.SiteTitle, Value: "AList", Type: conf.TypeString, Group: model.SITE},
|
||||
{Key: conf.SiteLogo, Value: "https://cdn.jsdelivr.net/gh/alist-org/logo@main/logo.svg", Type: conf.TypeString, Group: model.SITE},
|
||||
{Key: conf.Favicon, Value: "https://cdn.jsdelivr.net/gh/alist-org/logo@main/logo.svg", Type: conf.TypeString, Group: model.SITE},
|
||||
{Key: conf.Announcement, Value: "https://github.com/alist-org/alist", Type: conf.TypeString, Group: model.SITE},
|
||||
// style settings
|
||||
{Key: conf.Logo, Value: "https://cdn.jsdelivr.net/gh/alist-org/logo@main/logo.svg", Type: conf.TypeString, Group: model.STYLE},
|
||||
{Key: conf.Favicon, Value: "https://cdn.jsdelivr.net/gh/alist-org/logo@main/logo.svg", Type: conf.TypeString, Group: model.STYLE},
|
||||
{Key: conf.IconColor, Value: "#1890ff", Type: conf.TypeString, Group: model.STYLE},
|
||||
// preview settings
|
||||
{Key: conf.TextTypes, Value: "txt,htm,html,xml,java,properties,sql,js,md,json,conf,ini,vue,php,py,bat,gitignore,yml,go,sh,c,cpp,h,hpp,tsx,vtt,srt,ass,rs,lrc", Type: conf.TypeText, Group: model.PREVIEW, Flag: model.PRIVATE},
|
||||
|
@ -13,7 +13,7 @@ const (
|
||||
ApiUrl = "api_url"
|
||||
BasePath = "base_path"
|
||||
SiteTitle = "site_title"
|
||||
SiteLogo = "site_logo"
|
||||
Logo = "logo"
|
||||
Favicon = "favicon"
|
||||
Announcement = "announcement"
|
||||
IconColor = "icon_color"
|
||||
|
@ -54,6 +54,14 @@ func GetSettingItemByKey(key string) (*model.SettingItem, error) {
|
||||
return &settingItem, nil
|
||||
}
|
||||
|
||||
func GetSettingItemInKeys(keys []string) ([]model.SettingItem, error) {
|
||||
var settingItem []model.SettingItem
|
||||
if err := db.Where(fmt.Sprintf("%s in ?", columnName("key")), keys).Find(&settingItem).Error; err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
return settingItem, nil
|
||||
}
|
||||
|
||||
func GetPublicSettingItems() ([]model.SettingItem, error) {
|
||||
var settingItems []model.SettingItem
|
||||
if err := db.Where(fmt.Sprintf("%s in ?", columnName("flag")), []int{model.PUBLIC, model.READONLY}).Find(&settingItems).Error; err != nil {
|
||||
@ -70,6 +78,14 @@ func GetSettingItemsByGroup(group int) ([]model.SettingItem, error) {
|
||||
return settingItems, nil
|
||||
}
|
||||
|
||||
func GetSettingItemsInGroups(groups []int) ([]model.SettingItem, error) {
|
||||
var settingItems []model.SettingItem
|
||||
if err := db.Where(fmt.Sprintf("%s in ?", columnName("group")), groups).Find(&settingItems).Error; err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
return settingItems, nil
|
||||
}
|
||||
|
||||
func SaveSettingItems(items []model.SettingItem) error {
|
||||
settingsMap = nil
|
||||
return errors.WithStack(db.Save(items).Error)
|
||||
|
Reference in New Issue
Block a user