From b19a704aeef5da4eecba91c9680c00cf80b7d639 Mon Sep 17 00:00:00 2001 From: naiba <hi@nai.ba> Date: Sun, 24 Jan 2021 21:17:37 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20dayNight=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=20+=20=E4=B8=80=E4=BA=9B=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/dashboard/controller/member_page.go | 1 - cmd/playground/example.sh | 9 +++++++++ cmd/playground/main.go | 15 ++++++++------- pkg/mygin/mygin.go | 1 + resource/template/component/cron.html | 4 ++-- resource/template/theme-daynight/home.html | 12 ++++-------- resource/template/theme-daynight/service.html | 2 +- service/dao/dao.go | 2 +- 8 files changed, 26 insertions(+), 20 deletions(-) create mode 100755 cmd/playground/example.sh diff --git a/cmd/dashboard/controller/member_page.go b/cmd/dashboard/controller/member_page.go index 66ab61b..be09547 100644 --- a/cmd/dashboard/controller/member_page.go +++ b/cmd/dashboard/controller/member_page.go @@ -71,6 +71,5 @@ func (mp *memberPage) notification(c *gin.Context) { func (mp *memberPage) setting(c *gin.Context) { c.HTML(http.StatusOK, "dashboard/setting", mygin.CommonEnvironment(c, gin.H{ "Title": "系统设置", - "Conf": dao.Conf, })) } diff --git a/cmd/playground/example.sh b/cmd/playground/example.sh new file mode 100755 index 0000000..a6a5e09 --- /dev/null +++ b/cmd/playground/example.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -x + +ME=`whoami` + +ping example.com -c20 && \ + echo "==== $ME ====" && \ + ping example.net -c20 && \ + echo "==== done! ====" \ No newline at end of file diff --git a/cmd/playground/main.go b/cmd/playground/main.go index ceac57a..93402dc 100644 --- a/cmd/playground/main.go +++ b/cmd/playground/main.go @@ -6,6 +6,7 @@ import ( "log" "net" "net/http" + "os" "os/exec" "time" @@ -16,8 +17,9 @@ import ( func main() { // icmp() // tcpping() - httpWithSSLInfo() + // httpWithSSLInfo() // diskinfo() + cmdExec() } func tcpping() { @@ -71,13 +73,12 @@ func icmp() { } func cmdExec() { - cmd := exec.Command("ping", "example.com", "-c2") + execFrom, err := os.Getwd() + if err != nil { + panic(err) + } + cmd := exec.Command(execFrom + "/cmd/playground/example.sh") output, err := cmd.Output() log.Println("output:", string(output)) log.Println("err:", err) - - cmd = exec.Command("ping", "example", "-c2") - output, err = cmd.Output() - log.Println("output:", string(output)) - log.Println("err:", err) } diff --git a/pkg/mygin/mygin.go b/pkg/mygin/mygin.go index 81caed1..9199063 100644 --- a/pkg/mygin/mygin.go +++ b/pkg/mygin/mygin.go @@ -21,6 +21,7 @@ var adminPage = map[string]bool{ func CommonEnvironment(c *gin.Context, data map[string]interface{}) gin.H { data["MatchedPath"] = c.MustGet("MatchedPath") data["Version"] = dao.Version + data["Conf"] = dao.Conf // 是否是管理页面 data["IsAdminPage"] = adminPage[data["MatchedPath"].(string)] // 站点标题 diff --git a/resource/template/component/cron.html b/resource/template/component/cron.html index 7e2347b..efbcc7f 100644 --- a/resource/template/component/cron.html +++ b/resource/template/component/cron.html @@ -37,8 +37,8 @@ 计划的格式为:<code>* * * * *</code> 分 时 天 月 星期,详情见 <a href="https://pkg.go.dev/github.com/robfig/cron/v3#hdr-CRON_Expression_Format" target="_blank">计划表达式格式</a><br> - 命令:Shell 命令,就像写脚本一样就可以,如果遇到 xxx 命令找不到,可能是 <code>PATH</code> 环境变量的问题,<code>source ~/.bashrc</code> - 或者使用绝对路径执行。 + 命令:Shell 命令,就像写脚本一样就可以,如果遇到 xxx 命令找不到,可能是 <code>PATH</code> 环境变量的问题,在脚本顶部加一个 <code>source ~/.bashrc</code> + 或者使用绝对路径执行,示例 <a href="https://gist.github.com/naiba/26efc8bf6f0b3273a9ba15ee48db5f11" target="_blank" rel="noopener noreferrer">备份脚本</a>。 </p> </div> </div> diff --git a/resource/template/theme-daynight/home.html b/resource/template/theme-daynight/home.html index d967063..615821b 100644 --- a/resource/template/theme-daynight/home.html +++ b/resource/template/theme-daynight/home.html @@ -20,7 +20,7 @@ <body data-theme="light" data-gridlist="grid"> <header class="nav-bar clearfix"> - <figure class="logo"><a href="/">{{.Title}}</a></figure> + <figure class="logo"><a href="/">{{.Conf.Site.Brand}}</a></figure> <div class="icon-container"> <div class="row cf"> <div class="three col"> @@ -34,16 +34,12 @@ {{if .Admin}} <li><a href="/">首页</a></li> <li><a href="/service">服务状态</a></li> - <li><a href="/server">服务器</a></li> - <li><a href="/monitor">监控</a></li> - <li><a href="/notification">通知</a></li> - <li><a href="/setting">设置</a></li> - <li><a href="#" style="padding:.8em;text-align:center;" - title="您已登录">{{.Admin.Name}}</a></li> + <li><a href="/server" style="padding:.8em;text-align:center;">管理后台</a></li> {{else}} <li><a href="/">首页</a></li> <li><a href="/service">服务状态</a></li> - <li><a href="/login">登录</a></li>{{end}} + <li><a href="/login">登录</a></li> + {{end}} </ul> </nav> </header> diff --git a/resource/template/theme-daynight/service.html b/resource/template/theme-daynight/service.html index 69cbfa5..159ba4d 100644 --- a/resource/template/theme-daynight/service.html +++ b/resource/template/theme-daynight/service.html @@ -20,7 +20,7 @@ <body data-theme="light" data-gridlist="list"> <article> <header class="nav-bar clearfix"> - <figure class="logo"><a href="/">{{.Title}}</a></figure> + <figure class="logo"><a href="/">{{.Conf.Site.Brand}}</a></figure> <div class="icon-container"> <div class="row cf"> <div class="three col"> diff --git a/service/dao/dao.go b/service/dao/dao.go index 52b0b25..57f6c9c 100644 --- a/service/dao/dao.go +++ b/service/dao/dao.go @@ -13,7 +13,7 @@ import ( pb "github.com/naiba/nezha/proto" ) -var Version = "v0.3.9" +var Version = "v0.3.10" const ( SnapshotDelay = 3