diff --git a/bootstrap/model.go b/bootstrap/model.go index 9d94069431e..e72b4062410 100644 --- a/bootstrap/model.go +++ b/bootstrap/model.go @@ -206,6 +206,18 @@ func initSettings() { Type: "bool", Description: "check parent folder password", }, + { + Key: "customize style", + Value: "", + Type: "text", + Description: "customize style, don't need add ", + }, + { + Key: "customize script", + Value: "", + Type: "text", + Description: "customize script, don't need add ", + }, } for _, v := range settings { _, err := model.GetSettingByKey(v.Key) diff --git a/conf/var.go b/conf/var.go index f66bd1bf928..2192491d52f 100644 --- a/conf/var.go +++ b/conf/var.go @@ -37,5 +37,10 @@ var ( // settings var ( - CheckParent bool -) \ No newline at end of file + RawIndexHtml string + IndexHtml string + CheckParent bool + //CustomizeStyle string + //CustomizeScript string + //Favicon string +) diff --git a/model/setting.go b/model/setting.go index a8abd37fd08..e1c92a2136f 100644 --- a/model/setting.go +++ b/model/setting.go @@ -61,4 +61,19 @@ func LoadSettings() { if err == nil { conf.CheckParent = checkParent.Value == "true" } -} \ No newline at end of file + favicon, err := GetSettingByKey("favicon") + if err == nil { + //conf.Favicon = favicon.Value + conf.IndexHtml = strings.Replace(conf.RawIndexHtml, "https://store.heytapimage.com/cdo-portal/feedback/202110/30/d43c41c5d257c9bc36366e310374fb19.png", favicon.Value, 1) + } + customizeStyle, err := GetSettingByKey("customize style") + if err == nil { + //conf.CustomizeStyle = customizeStyle.Value + conf.IndexHtml = strings.Replace(conf.IndexHtml, "/* customize-style */", customizeStyle.Value, 1) + } + customizeScript, err := GetSettingByKey("customize script") + if err == nil { + //conf.CustomizeStyle = customizeScript.Value + conf.IndexHtml = strings.Replace(conf.IndexHtml, "// customize-js", customizeScript.Value, 1) + } +} diff --git a/server/static.go b/server/static.go index 9059b78f623..8d01c250412 100644 --- a/server/static.go +++ b/server/static.go @@ -1,6 +1,7 @@ package server import ( + "github.com/Xhofe/alist/conf" "github.com/Xhofe/alist/public" "github.com/gin-gonic/gin" log "github.com/sirupsen/logrus" @@ -9,11 +10,11 @@ import ( "net/http" ) -var data []byte func init() { index, _ := public.Public.Open("index.html") - data, _ = ioutil.ReadAll(index) + data, _ := ioutil.ReadAll(index) + conf.RawIndexHtml = string(data) } func Static(r *gin.Engine) { @@ -25,7 +26,7 @@ func Static(r *gin.Engine) { r.NoRoute(func(c *gin.Context) { c.Status(200) c.Header("Content-Type", "text/html") - _, _ = c.Writer.Write(data) + _, _ = c.Writer.WriteString(conf.IndexHtml) c.Writer.Flush() }) }