🎇 add local config

This commit is contained in:
微凉 2021-12-20 23:56:17 +08:00
parent 337bf08cd3
commit 1485ab2677
4 changed files with 17 additions and 7 deletions

View File

@ -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

View File

@ -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 {

View File

@ -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) {

View File

@ -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")