🔧 change config

This commit is contained in:
微凉 2022-01-14 20:10:35 +08:00
parent 55d244b726
commit fea8b376f8
4 changed files with 14 additions and 8 deletions

2
.gitignore vendored
View File

@ -23,7 +23,7 @@ dist/
bin/*
/alist
*.json
public/index.html
public/*.html
public/assets/
public/public/
data/

View File

@ -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())
}

View File

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

View File

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