mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 12:40:07 +00:00
feat(theme): 自定义主题
This commit is contained in:
@@ -29,7 +29,8 @@ func (cp *commonPage) home(c *gin.Context) {
|
||||
dao.ServerLock.RLock()
|
||||
defer dao.ServerLock.RUnlock()
|
||||
data := gin.H{
|
||||
"Servers": dao.ServerList,
|
||||
"Servers": dao.ServerList,
|
||||
"CustomCSS": dao.Conf.Site.CustomCSS,
|
||||
}
|
||||
u, ok := c.Get(model.CtxKeyAuthorizedUser)
|
||||
if ok {
|
||||
|
||||
@@ -3,6 +3,7 @@ package controller
|
||||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.cloudfoundry.org/bytefmt"
|
||||
@@ -24,6 +25,9 @@ func ServeWeb(port uint) {
|
||||
"tf": func(t time.Time) string {
|
||||
return t.Format("2006年1月2号")
|
||||
},
|
||||
"css": func(s string) template.CSS {
|
||||
return template.CSS(s)
|
||||
},
|
||||
"stf": func(s uint64) string {
|
||||
return time.Unix(int64(s), 0).Format("2006年1月2号 15:04")
|
||||
},
|
||||
@@ -33,6 +37,9 @@ func ServeWeb(port uint) {
|
||||
"bf": func(b uint64) string {
|
||||
return bytefmt.ByteSize(b)
|
||||
},
|
||||
"ts": func(s string) string {
|
||||
return strings.TrimSpace(s)
|
||||
},
|
||||
})
|
||||
r.Static("/static", "resource/static")
|
||||
r.LoadHTMLGlob("resource/template/**/*")
|
||||
|
||||
@@ -127,9 +127,10 @@ func (ma *memberAPI) logout(c *gin.Context) {
|
||||
}
|
||||
|
||||
type settingForm struct {
|
||||
Title string
|
||||
Admin string
|
||||
Theme string
|
||||
Title string
|
||||
Admin string
|
||||
Theme string
|
||||
CustomCSS string
|
||||
}
|
||||
|
||||
func (ma *memberAPI) updateSetting(c *gin.Context) {
|
||||
@@ -143,6 +144,7 @@ func (ma *memberAPI) updateSetting(c *gin.Context) {
|
||||
}
|
||||
dao.Conf.Site.Brand = sf.Title
|
||||
dao.Conf.Site.Theme = sf.Theme
|
||||
dao.Conf.Site.CustomCSS = sf.CustomCSS
|
||||
dao.Conf.GitHub.Admin = sf.Admin
|
||||
if err := dao.Conf.Save(); err != nil {
|
||||
c.JSON(http.StatusOK, model.Response{
|
||||
|
||||
Reference in New Issue
Block a user