mirror of https://github.com/Xhofe/alist
✨ add settings
parent
2c675ae909
commit
e902c2ded7
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -34,3 +34,8 @@ var (
|
|||
AudioTypes = []string{"mp3", "flac", "ogg", "m4a"}
|
||||
ImageTypes = []string{"jpg", "tiff", "jpeg", "png", "gif", "bmp", "svg"}
|
||||
)
|
||||
|
||||
// settings
|
||||
var (
|
||||
CheckParent bool
|
||||
)
|
|
@ -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"
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue