mirror of https://github.com/Xhofe/alist
✨ add settings
parent
2c675ae909
commit
e902c2ded7
|
@ -189,6 +189,22 @@ func initSettings() {
|
||||||
Type: "select",
|
Type: "select",
|
||||||
Values: "default,github,vuepress",
|
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 {
|
for _, v := range settings {
|
||||||
_, err := model.GetSettingByKey(v.Key)
|
_, err := model.GetSettingByKey(v.Key)
|
||||||
|
@ -199,8 +215,5 @@ func initSettings() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
textTypes, err := model.GetSettingByKey("text types")
|
model.LoadSettings()
|
||||||
if err == nil {
|
|
||||||
conf.TextTypes = strings.Split(textTypes.Value, ",")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,3 +34,8 @@ var (
|
||||||
AudioTypes = []string{"mp3", "flac", "ogg", "m4a"}
|
AudioTypes = []string{"mp3", "flac", "ogg", "m4a"}
|
||||||
ImageTypes = []string{"jpg", "tiff", "jpeg", "png", "gif", "bmp", "svg"}
|
ImageTypes = []string{"jpg", "tiff", "jpeg", "png", "gif", "bmp", "svg"}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// settings
|
||||||
|
var (
|
||||||
|
CheckParent bool
|
||||||
|
)
|
|
@ -2,6 +2,7 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/Xhofe/alist/conf"
|
"github.com/Xhofe/alist/conf"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -50,3 +51,14 @@ func GetSettingByKey(key string) (*SettingItem, error) {
|
||||||
}
|
}
|
||||||
return &items, nil
|
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
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/Xhofe/alist/conf"
|
|
||||||
"github.com/Xhofe/alist/model"
|
"github.com/Xhofe/alist/model"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func SaveSettings(ctx *fiber.Ctx) error {
|
func SaveSettings(ctx *fiber.Ctx) error {
|
||||||
|
@ -18,10 +16,7 @@ func SaveSettings(ctx *fiber.Ctx) error {
|
||||||
if err := model.SaveSettings(req); err != nil {
|
if err := model.SaveSettings(req); err != nil {
|
||||||
return ErrorResp(ctx, err, 500)
|
return ErrorResp(ctx, err, 500)
|
||||||
} else {
|
} else {
|
||||||
textTypes, err := model.GetSettingByKey("text types")
|
model.LoadSettings()
|
||||||
if err==nil{
|
|
||||||
conf.TextTypes = strings.Split(textTypes.Value,",")
|
|
||||||
}
|
|
||||||
return SuccessResp(ctx)
|
return SuccessResp(ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue