mirror of
https://github.com/AlistGo/alist.git
synced 2025-04-23 13:54:04 +08:00
🎇 add local config
This commit is contained in:
parent
337bf08cd3
commit
1485ab2677
7
build.sh
7
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
|
||||
|
@ -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 {
|
||||
|
@ -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) {
|
||||
|
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user