grouping settings

This commit is contained in:
Xhofe
2021-12-28 16:38:56 +08:00
parent 04752f7473
commit 4c00866249
3 changed files with 95 additions and 62 deletions

View File

@ -10,16 +10,8 @@ import (
func InitSettings() {
log.Infof("init settings...")
version := model.SettingItem{
Key: "version",
Value: conf.GitTag,
Description: "version",
Type: "string",
Group: model.CONST,
Version: conf.GitTag,
}
err := model.SaveSetting(version)
err := model.SaveSetting(model.Version)
if err != nil {
log.Fatalf("failed write setting: %s", err.Error())
}
@ -30,153 +22,155 @@ func InitSettings() {
Value: "Alist",
Description: "title",
Type: "string",
Group: model.PUBLIC,
Access: model.PUBLIC,
Group: model.FRONT,
},
{
Key: "password",
Value: "alist",
Description: "password",
Type: "string",
Group: model.PRIVATE,
Access: model.PRIVATE,
Group: model.BACK,
},
{
Key: "logo",
Value: "https://store.heytapimage.com/cdo-portal/feedback/202112/05/1542f45f86b8609495b69c5380753135.png",
Description: "logo",
Type: "string",
Group: model.PUBLIC,
Access: model.PUBLIC,
Group: model.FRONT,
},
{
Key: "favicon",
Value: "https://store.heytapimage.com/cdo-portal/feedback/202112/05/1542f45f86b8609495b69c5380753135.png",
Description: "favicon",
Type: "string",
Group: model.PUBLIC,
Access: model.PUBLIC,
Group: model.FRONT,
},
{
Key: "icon color",
Value: "#1890ff",
Description: "icon's color",
Type: "string",
Group: model.PUBLIC,
Access: model.PUBLIC,
Group: model.FRONT,
},
{
Key: "text types",
Value: strings.Join(conf.TextTypes, ","),
Type: "string",
Description: "text type extensions",
Group: model.FRONT,
},
{
Key: "hide readme file",
Value: "true",
Type: "bool",
Description: "hide readme file? ",
Group: model.FRONT,
},
{
Key: "music cover",
Value: "https://store.heytapimage.com/cdo-portal/feedback/202110/30/d43c41c5d257c9bc36366e310374fb19.png",
Description: "music cover image",
Type: "string",
Group: model.PUBLIC,
Access: model.PUBLIC,
Group: model.FRONT,
},
{
Key: "site beian",
Description: "chinese beian info",
Type: "string",
Group: model.PUBLIC,
Access: model.PUBLIC,
Group: model.FRONT,
},
{
Key: "home readme url",
Description: "when have multiple, the readme file to show",
Type: "string",
Group: model.PUBLIC,
Access: model.PUBLIC,
Group: model.FRONT,
},
{
Key: "markdown theme",
Value: "vuepress",
Description: "default | github | vuepress",
Group: model.PUBLIC,
Access: model.PUBLIC,
Type: "select",
Values: "default,github,vuepress",
Group: model.FRONT,
},
{
Key: "autoplay video",
Value: "false",
Type: "bool",
Group: model.PUBLIC,
Key: "autoplay video",
Value: "false",
Type: "bool",
Access: model.PUBLIC,
Group: model.FRONT,
},
{
Key: "autoplay audio",
Value: "false",
Type: "bool",
Group: model.PUBLIC,
Key: "autoplay audio",
Value: "false",
Type: "bool",
Access: model.PUBLIC,
Group: model.FRONT,
},
{
Key: "check parent folder",
Value: "false",
Type: "bool",
Description: "check parent folder password",
Group: model.PRIVATE,
Access: model.PRIVATE,
Group: model.BACK,
},
{
Key: "customize head",
Value: `<style>
.chakra-ui-light{
background-color: #edddfd;
}
.main-box {
border-radius: 15px !important;
box-shadow: unset !important;
}
.chakra-ui-light .main-box {
background-color: rgba(255,255,255,0.9) !important;
}
.chakra-ui-light .readme-box {
background-color: rgba(255,255,255,0.9) !important;
}
.readme-box {
border-radius: 15px !important;
box-shadow: unset !important;
}
</style>`,
Key: "customize head",
Value: "",
Type: "text",
Description: "Customize head, placed at the beginning of the head",
Group: model.PRIVATE,
Access: model.PRIVATE,
Group: model.FRONT,
},
{
Key: "customize body",
Value: "",
Type: "text",
Description: "Customize script, placed at the end of the body",
Group: model.PRIVATE,
Access: model.PRIVATE,
Group: model.FRONT,
},
{
Key: "animation",
Value: "true",
Type: "bool",
Description: "when there are a lot of files, the animation will freeze when opening",
Group: model.PUBLIC,
Access: model.PUBLIC,
Group: model.FRONT,
},
{
Key: "check down link",
Value: "false",
Type: "bool",
Description: "check down link password, your link will be 'https://alist.com/d/filename?pw=xxx'",
Group: model.PUBLIC,
Access: model.PUBLIC,
Group: model.BACK,
},
{
Key: "WebDAV username",
Value: "alist",
Description: "WebDAV username",
Type: "string",
Group: model.PRIVATE,
Access: model.PRIVATE,
Group: model.BACK,
},
{
Key: "WebDAV password",
Value: "alist",
Description: "WebDAV password",
Type: "string",
Group: model.PRIVATE,
Access: model.PRIVATE,
Group: model.BACK,
},
}
for i, _ := range settings {
@ -193,8 +187,10 @@ func InitSettings() {
log.Fatal("can't get setting: %s", err.Error())
}
} else {
o.Version = conf.GitTag
err = model.SaveSetting(*o)
//o.Version = conf.GitTag
//err = model.SaveSetting(*o)
v.Value = o.Value
err = model.SaveSetting(v)
if err != nil {
log.Fatalf("failed write setting: %s", err.Error())
}