From fea8b376f8dd96ce74abad3cbacc4011a10ee3e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=AE=E5=87=89?= <927625802@qq.com> Date: Fri, 14 Jan 2022 20:10:35 +0800 Subject: [PATCH] :wrench: change config --- .gitignore | 2 +- bootstrap/conf.go | 2 +- conf/config.go | 3 ++- server/static.go | 15 ++++++++++----- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 7857dea7..ffbe096b 100644 --- a/.gitignore +++ b/.gitignore @@ -23,7 +23,7 @@ dist/ bin/* /alist *.json -public/index.html +public/*.html public/assets/ public/public/ data/ \ No newline at end of file diff --git a/bootstrap/conf.go b/bootstrap/conf.go index 46d9761b..ba6596a9 100644 --- a/bootstrap/conf.go +++ b/bootstrap/conf.go @@ -33,7 +33,7 @@ func InitConf() { } log.Debugf("config:%+v", conf.Conf) // update config.json struct - confBody, err := utils.Json.Marshal(conf.Conf) + confBody, err := utils.Json.MarshalIndent(conf.Conf, "", " ") if err != nil { log.Fatalf("marshal config error:%s", err.Error()) } diff --git a/conf/config.go b/conf/config.go index 9efb19ed..f0324eba 100644 --- a/conf/config.go +++ b/conf/config.go @@ -25,7 +25,7 @@ type CacheConfig struct { type Config struct { Address string `json:"address"` Port int `json:"port"` - Local bool `json:"local"` + Assets string `json:"assets"` Database Database `json:"database"` Scheme Scheme `json:"scheme"` Cache CacheConfig `json:"cache"` @@ -35,6 +35,7 @@ func DefaultConfig() *Config { return &Config{ Address: "0.0.0.0", Port: 5244, + Assets: "jsdelivr", Database: Database{ Type: "sqlite3", Port: 0, diff --git a/server/static.go b/server/static.go index 9530b880..015c681c 100644 --- a/server/static.go +++ b/server/static.go @@ -1,6 +1,7 @@ package server import ( + "fmt" "github.com/Xhofe/alist/conf" "github.com/Xhofe/alist/public" "github.com/gin-gonic/gin" @@ -14,13 +15,17 @@ import ( func InitIndex() { var index fs.File var err error - if conf.Conf.Local { - index, err = public.Public.Open("local.html") - } else { - index, err = public.Public.Open("index.html") + //if conf.Conf.Local { + // index, err = public.Public.Open("local.html") + //} else { + // index, err = public.Public.Open("index.html") + //} + if conf.Conf.Assets == "" { + conf.Conf.Assets = "jsdelivr" } + index, err = public.Public.Open(fmt.Sprintf("%s.html", conf.Conf.Assets)) if err != nil { - //log.Fatalf(err.Error()) + log.Fatalf(err.Error()) return } data, _ := ioutil.ReadAll(index)