🎇 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
|
if [ "$1" == "release" ]; then
|
||||||
yarn build --base="https://cdn.jsdelivr.net/gh/Xhofe/alist-web@cdn/v2/$webCommit"
|
yarn build --base="https://cdn.jsdelivr.net/gh/Xhofe/alist-web@cdn/v2/$webCommit"
|
||||||
mv dist/assets ..
|
mv dist/assets ..
|
||||||
|
mv dist/ ../alist/public
|
||||||
|
# 构建local
|
||||||
|
yarn build
|
||||||
|
mv dist/index.html dist/local.html
|
||||||
|
mv dist/ ../alist/public
|
||||||
else
|
else
|
||||||
yarn build
|
yarn build
|
||||||
fi
|
fi
|
||||||
@ -61,8 +66,6 @@ ldflags="\
|
|||||||
-X 'github.com/Xhofe/alist/conf.GitTag=$gitTag' \
|
-X 'github.com/Xhofe/alist/conf.GitTag=$gitTag' \
|
||||||
"
|
"
|
||||||
|
|
||||||
cp -R ../alist-web/dist/* public
|
|
||||||
|
|
||||||
if [ "$1" == "release" ]; then
|
if [ "$1" == "release" ]; then
|
||||||
xgo -out alist -ldflags="$ldflags" .
|
xgo -out alist -ldflags="$ldflags" .
|
||||||
else
|
else
|
||||||
|
@ -17,6 +17,7 @@ type Config struct {
|
|||||||
Https bool `json:"https"`
|
Https bool `json:"https"`
|
||||||
CertFile string `json:"cert_file"`
|
CertFile string `json:"cert_file"`
|
||||||
KeyFile string `json:"key_file"`
|
KeyFile string `json:"key_file"`
|
||||||
|
Local bool `json:"local"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func DefaultConfig() *Config {
|
func DefaultConfig() *Config {
|
||||||
|
@ -49,8 +49,8 @@ func InitApiRouter(r *gin.Engine) {
|
|||||||
|
|
||||||
admin.POST("/link", controllers.Link)
|
admin.POST("/link", controllers.Link)
|
||||||
}
|
}
|
||||||
Static(r)
|
|
||||||
WebDav(r)
|
WebDav(r)
|
||||||
|
Static(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Cors(r *gin.Engine) {
|
func Cors(r *gin.Engine) {
|
||||||
|
@ -10,11 +10,16 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func InitIndex() {
|
||||||
func init() {
|
var index fs.File
|
||||||
index, err := public.Public.Open("index.html")
|
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 {
|
if err != nil {
|
||||||
log.Errorf(err.Error())
|
log.Fatalf(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, _ := ioutil.ReadAll(index)
|
data, _ := ioutil.ReadAll(index)
|
||||||
@ -22,6 +27,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Static(r *gin.Engine) {
|
func Static(r *gin.Engine) {
|
||||||
|
InitIndex()
|
||||||
assets, err := fs.Sub(public.Public, "assets")
|
assets, err := fs.Sub(public.Public, "assets")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("can't find assets folder")
|
log.Fatalf("can't find assets folder")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user