change proxy setting

This commit is contained in:
微凉
2021-11-17 17:20:57 +08:00
parent 0b7f2fee7d
commit 3d9746485d
8 changed files with 202 additions and 151 deletions

View File

@ -3,7 +3,6 @@ package bootstrap
import (
"fmt"
"github.com/Xhofe/alist/conf"
"github.com/Xhofe/alist/drivers"
"github.com/Xhofe/alist/model"
log "github.com/sirupsen/logrus"
"gorm.io/driver/mysql"
@ -79,152 +78,3 @@ func InitModel() {
}
}
func InitAccounts() {
log.Infof("init accounts...")
var accounts []model.Account
if err := conf.DB.Find(&accounts).Error; err != nil {
log.Fatalf("failed sync init accounts")
}
for i, account := range accounts {
model.RegisterAccount(account)
driver, ok := drivers.GetDriver(account.Type)
if !ok {
log.Errorf("no [%s] driver", driver)
} else {
err := driver.Save(&accounts[i], nil)
if err != nil {
log.Errorf("init account [%s] error:[%s]", account.Name, err.Error())
} else {
log.Infof("success init account: %s, type: %s", account.Name, account.Type)
}
}
}
}
func InitSettings() {
log.Infof("init settings...")
version := model.SettingItem{
Key: "version",
Value: conf.GitTag,
Description: "version",
Type: "string",
Group: model.CONST,
}
_ = model.SaveSetting(version)
settings := []model.SettingItem{
{
Key: "title",
Value: "Alist",
Description: "title",
Type: "string",
Group: model.PUBLIC,
},
{
Key: "password",
Value: "alist",
Description: "password",
Type: "string",
Group: model.PRIVATE,
},
{
Key: "logo",
Value: "https://store.heytapimage.com/cdo-portal/feedback/202110/30/d43c41c5d257c9bc36366e310374fb19.png",
Description: "logo",
Type: "string",
Group: model.PUBLIC,
},
{
Key: "favicon",
Value: "https://store.heytapimage.com/cdo-portal/feedback/202110/30/d43c41c5d257c9bc36366e310374fb19.png",
Description: "favicon",
Type: "string",
Group: model.PUBLIC,
},
{
Key: "icon color",
Value: "teal.300",
Description: "icon's color",
Type: "string",
Group: model.PUBLIC,
},
{
Key: "text types",
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",
Type: "string",
Description: "text type extensions",
},
{
Key: "hide readme file",
Value: "true",
Type: "bool",
Description: "hide readme file? ",
},
{
Key: "music cover",
Value: "https://store.heytapimage.com/cdo-portal/feedback/202110/30/d43c41c5d257c9bc36366e310374fb19.png",
Description: "music cover image",
Type: "string",
Group: model.PUBLIC,
},
{
Key: "site beian",
Description: "chinese beian info",
Type: "string",
Group: model.PUBLIC,
},
{
Key: "home readme url",
Description: "when have multiple, the readme file to show",
Type: "string",
Group: model.PUBLIC,
},
{
Key: "markdown theme",
Value: "vuepress",
Description: "default | github | vuepress",
Group: model.PUBLIC,
Type: "select",
Values: "default,github,vuepress",
},
{
Key: "autoplay video",
Value: "false",
Type: "bool",
},
{
Key: "autoplay audio",
Value: "false",
Type: "bool",
},
{
Key: "check parent folder",
Value: "false",
Type: "bool",
Description: "check parent folder password",
},
{
Key: "customize style",
Value: "",
Type: "text",
Description: "customize style, don't need add <style></style>",
},
{
Key: "customize script",
Value: "",
Type: "text",
Description: "customize script, don't need add <script></script>",
},
}
for _, v := range settings {
_, err := model.GetSettingByKey(v.Key)
if err == gorm.ErrRecordNotFound {
err = model.SaveSetting(v)
if err != nil {
log.Fatalf("failed write setting: %s", err.Error())
}
}
}
model.LoadSettings()
}