🔧 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/* bin/*
/alist /alist
*.json *.json
public/index.html public/*.html
public/assets/ public/assets/
public/public/ public/public/
data/ data/

View File

@ -33,7 +33,7 @@ func InitConf() {
} }
log.Debugf("config:%+v", conf.Conf) log.Debugf("config:%+v", conf.Conf)
// update config.json struct // update config.json struct
confBody, err := utils.Json.Marshal(conf.Conf) confBody, err := utils.Json.MarshalIndent(conf.Conf, "", " ")
if err != nil { if err != nil {
log.Fatalf("marshal config error:%s", err.Error()) log.Fatalf("marshal config error:%s", err.Error())
} }

View File

@ -25,7 +25,7 @@ type CacheConfig struct {
type Config struct { type Config struct {
Address string `json:"address"` Address string `json:"address"`
Port int `json:"port"` Port int `json:"port"`
Local bool `json:"local"` Assets string `json:"assets"`
Database Database `json:"database"` Database Database `json:"database"`
Scheme Scheme `json:"scheme"` Scheme Scheme `json:"scheme"`
Cache CacheConfig `json:"cache"` Cache CacheConfig `json:"cache"`
@ -35,6 +35,7 @@ func DefaultConfig() *Config {
return &Config{ return &Config{
Address: "0.0.0.0", Address: "0.0.0.0",
Port: 5244, Port: 5244,
Assets: "jsdelivr",
Database: Database{ Database: Database{
Type: "sqlite3", Type: "sqlite3",
Port: 0, Port: 0,

View File

@ -1,6 +1,7 @@
package server package server
import ( import (
"fmt"
"github.com/Xhofe/alist/conf" "github.com/Xhofe/alist/conf"
"github.com/Xhofe/alist/public" "github.com/Xhofe/alist/public"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -14,13 +15,17 @@ import (
func InitIndex() { func InitIndex() {
var index fs.File var index fs.File
var err error var err error
if conf.Conf.Local { //if conf.Conf.Local {
index, err = public.Public.Open("local.html") // index, err = public.Public.Open("local.html")
} else { //} else {
index, err = public.Public.Open("index.html") // 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 { if err != nil {
//log.Fatalf(err.Error()) log.Fatalf(err.Error())
return return
} }
data, _ := ioutil.ReadAll(index) data, _ := ioutil.ReadAll(index)