mirror of https://github.com/Xhofe/alist
parent
0f93d2bfed
commit
0dffb9aaa1
|
@ -206,6 +206,18 @@ func initSettings() {
|
||||||
Type: "bool",
|
Type: "bool",
|
||||||
Description: "check parent folder password",
|
Description: "check parent folder password",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Key: "customize style",
|
||||||
|
Value: "",
|
||||||
|
Type: "text",
|
||||||
|
Description: "customize style, don't need add <style></style>",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Key: "customize script",
|
||||||
|
Value: "",
|
||||||
|
Type: "text",
|
||||||
|
Description: "customize script, don't need add <script></script>",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, v := range settings {
|
for _, v := range settings {
|
||||||
_, err := model.GetSettingByKey(v.Key)
|
_, err := model.GetSettingByKey(v.Key)
|
||||||
|
|
|
@ -37,5 +37,10 @@ var (
|
||||||
|
|
||||||
// settings
|
// settings
|
||||||
var (
|
var (
|
||||||
|
RawIndexHtml string
|
||||||
|
IndexHtml string
|
||||||
CheckParent bool
|
CheckParent bool
|
||||||
|
//CustomizeStyle string
|
||||||
|
//CustomizeScript string
|
||||||
|
//Favicon string
|
||||||
)
|
)
|
|
@ -61,4 +61,19 @@ func LoadSettings() {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
conf.CheckParent = checkParent.Value == "true"
|
conf.CheckParent = checkParent.Value == "true"
|
||||||
}
|
}
|
||||||
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"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"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
@ -9,11 +10,11 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
var data []byte
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
index, _ := public.Public.Open("index.html")
|
index, _ := public.Public.Open("index.html")
|
||||||
data, _ = ioutil.ReadAll(index)
|
data, _ := ioutil.ReadAll(index)
|
||||||
|
conf.RawIndexHtml = string(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Static(r *gin.Engine) {
|
func Static(r *gin.Engine) {
|
||||||
|
@ -25,7 +26,7 @@ func Static(r *gin.Engine) {
|
||||||
r.NoRoute(func(c *gin.Context) {
|
r.NoRoute(func(c *gin.Context) {
|
||||||
c.Status(200)
|
c.Status(200)
|
||||||
c.Header("Content-Type", "text/html")
|
c.Header("Content-Type", "text/html")
|
||||||
_, _ = c.Writer.Write(data)
|
_, _ = c.Writer.WriteString(conf.IndexHtml)
|
||||||
c.Writer.Flush()
|
c.Writer.Flush()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue