diff --git a/bootstrap/model.go b/bootstrap/model.go index f8f08aaa..1214e2b3 100644 --- a/bootstrap/model.go +++ b/bootstrap/model.go @@ -189,6 +189,22 @@ func initSettings() { Type: "select", Values: "default,github,vuepress", }, + { + Key: "autoplay video", + Value: "true", + Type: "bool", + }, + { + Key: "autoplay audio", + Value: "true", + Type: "bool", + }, + { + Key: "check parent folder", + Value: "true", + Type: "bool", + Description: "check parent folder password", + }, } for _, v := range settings { _, err := model.GetSettingByKey(v.Key) @@ -199,8 +215,5 @@ func initSettings() { } } } - textTypes, err := model.GetSettingByKey("text types") - if err == nil { - conf.TextTypes = strings.Split(textTypes.Value, ",") - } + model.LoadSettings() } diff --git a/conf/var.go b/conf/var.go index 4b9527b3..f66bd1bf 100644 --- a/conf/var.go +++ b/conf/var.go @@ -34,3 +34,8 @@ var ( AudioTypes = []string{"mp3", "flac", "ogg", "m4a"} ImageTypes = []string{"jpg", "tiff", "jpeg", "png", "gif", "bmp", "svg"} ) + +// settings +var ( + CheckParent bool +) \ No newline at end of file diff --git a/model/setting.go b/model/setting.go index 08a1c6b6..e75d6672 100644 --- a/model/setting.go +++ b/model/setting.go @@ -2,6 +2,7 @@ package model import ( "github.com/Xhofe/alist/conf" + "strings" ) const ( @@ -50,3 +51,14 @@ func GetSettingByKey(key string) (*SettingItem, error) { } return &items, nil } + +func LoadSettings() { + textTypes, err := GetSettingByKey("text types") + if err == nil { + conf.TextTypes = strings.Split(textTypes.Value, ",") + } + checkParent, err := GetSettingByKey("check parent folder") + if err == nil { + conf.CheckParent = checkParent.Value == "true" + } +} \ No newline at end of file diff --git a/server/setting.go b/server/setting.go index d4e6b906..bbb05fb4 100644 --- a/server/setting.go +++ b/server/setting.go @@ -1,10 +1,8 @@ package server import ( - "github.com/Xhofe/alist/conf" "github.com/Xhofe/alist/model" "github.com/gofiber/fiber/v2" - "strings" ) func SaveSettings(ctx *fiber.Ctx) error { @@ -18,10 +16,7 @@ func SaveSettings(ctx *fiber.Ctx) error { if err := model.SaveSettings(req); err != nil { return ErrorResp(ctx, err, 500) } else { - textTypes, err := model.GetSettingByKey("text types") - if err==nil{ - conf.TextTypes = strings.Split(textTypes.Value,",") - } + model.LoadSettings() return SuccessResp(ctx) } }