diff --git a/build.sh b/build.sh index 3f156a5a..a4f8a164 100644 --- a/build.sh +++ b/build.sh @@ -37,6 +37,11 @@ yarn if [ "$1" == "release" ]; then yarn build --base="https://cdn.jsdelivr.net/gh/Xhofe/alist-web@cdn/v2/$webCommit" mv dist/assets .. + mv dist/ ../alist/public + # 构建local + yarn build + mv dist/index.html dist/local.html + mv dist/ ../alist/public else yarn build fi @@ -61,8 +66,6 @@ ldflags="\ -X 'github.com/Xhofe/alist/conf.GitTag=$gitTag' \ " -cp -R ../alist-web/dist/* public - if [ "$1" == "release" ]; then xgo -out alist -ldflags="$ldflags" . else diff --git a/conf/config.go b/conf/config.go index b83999b6..147dba83 100644 --- a/conf/config.go +++ b/conf/config.go @@ -17,6 +17,7 @@ type Config struct { Https bool `json:"https"` CertFile string `json:"cert_file"` KeyFile string `json:"key_file"` + Local bool `json:"local"` } func DefaultConfig() *Config { diff --git a/server/router.go b/server/router.go index 36f71ed8..9645cd56 100644 --- a/server/router.go +++ b/server/router.go @@ -49,8 +49,8 @@ func InitApiRouter(r *gin.Engine) { admin.POST("/link", controllers.Link) } - Static(r) WebDav(r) + Static(r) } func Cors(r *gin.Engine) { diff --git a/server/static.go b/server/static.go index 83825743..4a845f31 100644 --- a/server/static.go +++ b/server/static.go @@ -10,11 +10,16 @@ import ( "net/http" ) - -func init() { - index, err := public.Public.Open("index.html") +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 err != nil { - log.Errorf(err.Error()) + log.Fatalf(err.Error()) return } data, _ := ioutil.ReadAll(index) @@ -22,6 +27,7 @@ func init() { } func Static(r *gin.Engine) { + InitIndex() assets, err := fs.Sub(public.Public, "assets") if err != nil { log.Fatalf("can't find assets folder")