From ade06839b72bc33c41e7429468ff605e11b12228 Mon Sep 17 00:00:00 2001 From: naiba Date: Sat, 30 Apr 2022 00:48:39 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=94=96=20`dashboard=20v0.13.0`=20Glob?= =?UTF-8?q?alization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- cmd/dashboard/controller/member_api.go | 4 ++++ cmd/dashboard/controller/oauth2.go | 2 +- pkg/utils/utils.go | 11 +++++++++++ resource/template/common/menu.html | 4 ++-- resource/template/dashboard/setting.html | 10 ++++++++++ script/config.yaml | 1 + script/install.sh | 2 +- script/install_en.sh | 4 +++- service/singleton/l10n.go | 21 ++++++++++++++++----- service/singleton/singleton.go | 2 +- 11 files changed, 52 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 175a68a..479e494 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@
LOGO designed by 熊大 .

-    +    

:trollface: Nezha Monitoring One-stop light monitoring and light operation and maintenance system. Supports system status, HTTP (SSL certificate change, upcoming expiration, expiration), TCP, Ping monitoring and alarm, scheduled tasks and web terminal.

@@ -14,7 +14,7 @@ \>> QQ 交流群:872069346 **加群要求:已搭建好哪吒监控 & 有 2+ 服务器, 机器人自动审核** -\>> [Use Cases | 我们的用户](https://www.google.com/search?q="powered+by+哪吒监控"&filter=0) (Google) +\>> [Use Cases | 我们的用户](https://www.google.com/search?q=%22powered+by+%E5%93%AA%E5%90%92%E7%9B%91%E6%8E%A7%22+OR+%22powered+by+Nezha+Monitoring%22&filter=0) (Google) | Default Theme | DayNight [@JackieSung](https://github.com/JackieSung4ev) | hotaru | | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- | diff --git a/cmd/dashboard/controller/member_api.go b/cmd/dashboard/controller/member_api.go index 93865e1..1b4f2c8 100644 --- a/cmd/dashboard/controller/member_api.go +++ b/cmd/dashboard/controller/member_api.go @@ -551,6 +551,7 @@ func (ma *memberAPI) logout(c *gin.Context) { type settingForm struct { Title string Admin string + Language string Theme string CustomCode string ViewPassword string @@ -572,6 +573,7 @@ func (ma *memberAPI) updateSetting(c *gin.Context) { }) return } + singleton.Conf.Language = sf.Language singleton.Conf.EnableIPChangeNotification = sf.EnableIPChangeNotification == "on" singleton.Conf.EnablePlainIPInNotification = sf.EnablePlainIPInNotification == "on" singleton.Conf.Cover = sf.Cover @@ -594,6 +596,8 @@ func (ma *memberAPI) updateSetting(c *gin.Context) { }) return } + // 更新系统语言 + singleton.InitLocalizer() c.JSON(http.StatusOK, model.Response{ Code: http.StatusOK, }) diff --git a/cmd/dashboard/controller/oauth2.go b/cmd/dashboard/controller/oauth2.go index 200809b..38010b5 100644 --- a/cmd/dashboard/controller/oauth2.go +++ b/cmd/dashboard/controller/oauth2.go @@ -108,7 +108,7 @@ func (oa *oauth2controller) callback(c *gin.Context) { } var isAdmin bool for _, admin := range strings.Split(singleton.Conf.Oauth2.Admin, ",") { - if admin != "" && gu.GetLogin() == admin { + if admin != "" && strings.ToLower(gu.GetLogin()) == strings.ToLower(admin) { isAdmin = true break } diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 5989423..5f8cacd 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -68,3 +68,14 @@ func IPDesensitize(ipAddr string) string { ipAddr = ipv6Desensitize(ipAddr) return ipAddr } + +func PathExists(path string) (bool, error) { + _, err := os.Stat(path) + if err == nil { + return true, nil + } + if os.IsNotExist(err) { + return false, nil + } + return false, err +} diff --git a/resource/template/common/menu.html b/resource/template/common/menu.html index 3423c4e..f909103 100644 --- a/resource/template/common/menu.html +++ b/resource/template/common/menu.html @@ -1,9 +1,9 @@ {{define "common/menu"}}
- +
diff --git a/resource/template/component/monitor.html b/resource/template/component/monitor.html index 5b4c09c..a6909e7 100644 --- a/resource/template/component/monitor.html +++ b/resource/template/component/monitor.html @@ -45,7 +45,7 @@
- +
diff --git a/resource/template/component/rule.html b/resource/template/component/rule.html index 5fc5c29..ca49976 100644 --- a/resource/template/component/rule.html +++ b/resource/template/component/rule.html @@ -13,7 +13,7 @@
- +
diff --git a/resource/template/dashboard/cron.html b/resource/template/dashboard/cron.html index febca61..c41c4c7 100644 --- a/resource/template/dashboard/cron.html +++ b/resource/template/dashboard/cron.html @@ -17,7 +17,7 @@ {{tr "Name"}} {{tr "Scheduler"}} {{tr "Command"}} - {{tr "NotificationMethod"}} + {{tr "NotificationMethodGroup"}} {{tr "PushSuccessfully"}} {{tr "Coverage"}} {{tr "SpecificServers"}} diff --git a/resource/template/dashboard/monitor.html b/resource/template/dashboard/monitor.html index 359aba4..41d2f52 100644 --- a/resource/template/dashboard/monitor.html +++ b/resource/template/dashboard/monitor.html @@ -19,7 +19,7 @@ {{tr "SpecificServers"}} {{tr "Type"}} {{tr "Duration"}} - {{tr "NotificationMethod"}} + {{tr "NotificationMethodGroup"}} {{tr "Notification"}} {{tr "Administration"}} diff --git a/resource/template/dashboard/notification.html b/resource/template/dashboard/notification.html index 3148efa..926b375 100644 --- a/resource/template/dashboard/notification.html +++ b/resource/template/dashboard/notification.html @@ -57,7 +57,7 @@ ID {{tr "Name"}} - {{tr "NotificationMethod"}} + {{tr "NotificationMethodGroup"}} {{tr "Rules"}} {{tr "Enable"}} {{tr "Administration"}} diff --git a/resource/template/dashboard/server.html b/resource/template/dashboard/server.html index 3401693..7b82b77 100644 --- a/resource/template/dashboard/server.html +++ b/resource/template/dashboard/server.html @@ -44,15 +44,11 @@ data-tooltip="{{tr "ClickToCopyTheInstallationCommand"}}"> - - {{$server.Note}} diff --git a/resource/template/dashboard/setting.html b/resource/template/dashboard/setting.html index 5dbcdab..f4e232c 100644 --- a/resource/template/dashboard/setting.html +++ b/resource/template/dashboard/setting.html @@ -6,7 +6,7 @@
- +
diff --git a/resource/template/theme-daynight/home.html b/resource/template/theme-daynight/home.html index a2ffd19..d3f14d8 100644 --- a/resource/template/theme-daynight/home.html +++ b/resource/template/theme-daynight/home.html @@ -23,7 +23,7 @@