From 76c789efd875cad7a358e9be49df338f05b27f71 Mon Sep 17 00:00:00 2001 From: naiba Date: Thu, 24 Dec 2020 09:54:17 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20=E5=A2=9E=E5=BC=BA=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E8=87=AA=E5=AE=9A=E4=B9=89CSS=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 32 +++++++++++++++++++++-- cmd/dashboard/controller/common_page.go | 4 +-- cmd/dashboard/controller/member_api.go | 10 +++---- model/config.go | 2 +- resource/template/dashboard/setting.html | 4 +-- resource/template/theme-default/home.html | 6 ++--- resource/template/theme-hotaru/home.html | 6 ++--- 7 files changed, 44 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index c7560c0..f7598a9 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ## 一键脚本 -**建议使用 WatchTower 自动更新面板,Windows监控可以使用nssm配置自启动** +**建议使用 WatchTower 自动更新面板,Windows监控可以使用nssm配置自启动** *记得加群获取面板更新通知,避免功能有更新面板自动更新后跟不上出问题* - 海外: @@ -27,22 +27,50 @@ ``` ## 使用说明 -### 自定义 CSS +### 自定义代码 + +可以去版权、改LOGO、加统计代码等等。 - 默认主题更改进度条颜色示例 ``` + + ``` +- 默认主题修改LOGO、移除版权示例(来自 mehui@hostloc 初版运用了XSS,有一点不足就是可以直接使用 pure JavaScript 实现用了 jQuery,欢迎PR) + + ``` + + + ``` - hotaru 主题更改背景图片示例 ``` + ``` ### 报警通知 diff --git a/cmd/dashboard/controller/common_page.go b/cmd/dashboard/controller/common_page.go index a2ee62e..cfe7c8a 100644 --- a/cmd/dashboard/controller/common_page.go +++ b/cmd/dashboard/controller/common_page.go @@ -27,8 +27,8 @@ func (cp *commonPage) home(c *gin.Context) { dao.ServerLock.RLock() defer dao.ServerLock.RUnlock() data := gin.H{ - "Servers": dao.ServerList, - "CustomCSS": dao.Conf.Site.CustomCSS, + "Servers": dao.ServerList, + "CustomCode": dao.Conf.Site.CustomCode, } u, ok := c.Get(model.CtxKeyAuthorizedUser) if ok { diff --git a/cmd/dashboard/controller/member_api.go b/cmd/dashboard/controller/member_api.go index efbe056..c7e9af8 100644 --- a/cmd/dashboard/controller/member_api.go +++ b/cmd/dashboard/controller/member_api.go @@ -252,10 +252,10 @@ func (ma *memberAPI) logout(c *gin.Context) { } type settingForm struct { - Title string - Admin string - Theme string - CustomCSS string + Title string + Admin string + Theme string + CustomCode string } func (ma *memberAPI) updateSetting(c *gin.Context) { @@ -269,7 +269,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.Site.CustomCode = sf.CustomCode dao.Conf.GitHub.Admin = sf.Admin if err := dao.Conf.Save(); err != nil { c.JSON(http.StatusOK, model.Response{ diff --git a/model/config.go b/model/config.go index 70d2b7c..1982f8e 100644 --- a/model/config.go +++ b/model/config.go @@ -17,7 +17,7 @@ type Config struct { Brand string // 站点名称 CookieName string // 浏览器 Cookie 名称 Theme string - CustomCSS string + CustomCode string } GitHub struct { Admin string // 管理员ID列表 diff --git a/resource/template/dashboard/setting.html b/resource/template/dashboard/setting.html index add9657..a65ab55 100644 --- a/resource/template/dashboard/setting.html +++ b/resource/template/dashboard/setting.html @@ -19,8 +19,8 @@
- - + +
diff --git a/resource/template/theme-default/home.html b/resource/template/theme-default/home.html index 703a317..639674a 100644 --- a/resource/template/theme-default/home.html +++ b/resource/template/theme-default/home.html @@ -1,9 +1,7 @@ {{define "theme-default/home"}} {{template "common/header" .}} -{{if ts .CustomCSS}} -{{tag "style"}} -{{.CustomCSS|safe}} -{{tag "/style"}} +{{if ts .CustomCode}} +{{.CustomCode|safe}} {{end}} {{template "common/menu" .}}
diff --git a/resource/template/theme-hotaru/home.html b/resource/template/theme-hotaru/home.html index fceb1f7..c473b8f 100644 --- a/resource/template/theme-hotaru/home.html +++ b/resource/template/theme-hotaru/home.html @@ -19,10 +19,8 @@ - {{if ts .CustomCSS}} - {{tag "style"}} - {{.CustomCSS|safe}} - {{tag "/style"}} + {{if ts .CustomCode}} + {{.CustomCode|safe}} {{end}}