parent
345511e90f
commit
1c2cc5dcab
@ -67,29 +67,20 @@ func (p *commonPage) service(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u, ok := c.Get(model.CtxKeyAuthorizedUser)
|
c.HTML(http.StatusOK, "theme-"+dao.Conf.Site.Theme+"/service", mygin.CommonEnvironment(c, gin.H{
|
||||||
data := mygin.CommonEnvironment(c, gin.H{
|
|
||||||
"Title": "服务状态",
|
"Title": "服务状态",
|
||||||
"Services": msm,
|
"Services": msm,
|
||||||
})
|
}))
|
||||||
if ok {
|
|
||||||
data["Admin"] = u
|
|
||||||
}
|
|
||||||
c.HTML(http.StatusOK, "theme-"+dao.Conf.Site.Theme+"/service", data)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cp *commonPage) home(c *gin.Context) {
|
func (cp *commonPage) home(c *gin.Context) {
|
||||||
dao.ServerLock.RLock()
|
dao.ServerLock.RLock()
|
||||||
defer dao.ServerLock.RUnlock()
|
defer dao.ServerLock.RUnlock()
|
||||||
data := gin.H{
|
|
||||||
|
c.HTML(http.StatusOK, "theme-"+dao.Conf.Site.Theme+"/home", mygin.CommonEnvironment(c, gin.H{
|
||||||
"Servers": dao.SortedServerList,
|
"Servers": dao.SortedServerList,
|
||||||
"CustomCode": dao.Conf.Site.CustomCode,
|
"CustomCode": dao.Conf.Site.CustomCode,
|
||||||
}
|
}))
|
||||||
u, ok := c.Get(model.CtxKeyAuthorizedUser)
|
|
||||||
if ok {
|
|
||||||
data["Admin"] = u
|
|
||||||
}
|
|
||||||
c.HTML(http.StatusOK, "theme-"+dao.Conf.Site.Theme+"/home", mygin.CommonEnvironment(c, data))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var upgrader = websocket.Upgrader{}
|
var upgrader = websocket.Upgrader{}
|
||||||
|
@ -10,9 +10,18 @@ import (
|
|||||||
"github.com/naiba/nezha/service/dao"
|
"github.com/naiba/nezha/service/dao"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var adminPage = map[string]bool{
|
||||||
|
"/server": true,
|
||||||
|
"/monitor": true,
|
||||||
|
"/setting": true,
|
||||||
|
"/notification": true,
|
||||||
|
}
|
||||||
|
|
||||||
func CommonEnvironment(c *gin.Context, data map[string]interface{}) gin.H {
|
func CommonEnvironment(c *gin.Context, data map[string]interface{}) gin.H {
|
||||||
data["MatchedPath"] = c.MustGet("MatchedPath")
|
data["MatchedPath"] = c.MustGet("MatchedPath")
|
||||||
data["Version"] = dao.Version
|
data["Version"] = dao.Version
|
||||||
|
// 是否是管理页面
|
||||||
|
data["IsAdminPage"] = adminPage[data["MatchedPath"].(string)]
|
||||||
// 站点标题
|
// 站点标题
|
||||||
if t, has := data["Title"]; !has {
|
if t, has := data["Title"]; !has {
|
||||||
data["Title"] = dao.Conf.Site.Brand
|
data["Title"] = dao.Conf.Site.Brand
|
||||||
|
@ -4,13 +4,14 @@
|
|||||||
<div class="item">
|
<div class="item">
|
||||||
<img src="/static/logo.png">
|
<img src="/static/logo.png">
|
||||||
</div>
|
</div>
|
||||||
<a class="item{{if eq .MatchedPath " /"}} active{{end}}" href="/">首页</a>
|
{{if .IsAdminPage}}
|
||||||
<a class="item{{if eq .MatchedPath " /service"}} active{{end}}" href="/service">服务状态</a>
|
|
||||||
{{if .Admin}}
|
|
||||||
<a class="item{{if eq .MatchedPath " /server"}} active{{end}}" href="/server">服务器</a>
|
<a class="item{{if eq .MatchedPath " /server"}} active{{end}}" href="/server">服务器</a>
|
||||||
<a class="item{{if eq .MatchedPath " /monitor"}} active{{end}}" href="/monitor">监控</a>
|
<a class="item{{if eq .MatchedPath " /monitor"}} active{{end}}" href="/monitor">服务监控</a>
|
||||||
<a class="item{{if eq .MatchedPath " /notification"}} active{{end}}" href="/notification">通知</a>
|
<a class="item{{if eq .MatchedPath " /notification"}} active{{end}}" href="/notification">通知</a>
|
||||||
<a class="item{{if eq .MatchedPath " /setting"}} active{{end}}" href="/setting">设置</a>
|
<a class="item{{if eq .MatchedPath " /setting"}} active{{end}}" href="/setting">设置</a>
|
||||||
|
{{else}}
|
||||||
|
<a class="item{{if eq .MatchedPath " /"}} active{{end}}" href="/">首页</a>
|
||||||
|
<a class="item{{if eq .MatchedPath " /service"}} active{{end}}" href="/service">服务状态</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
<div class="right menu">
|
<div class="right menu">
|
||||||
<div class="item">
|
<div class="item">
|
||||||
@ -21,6 +22,15 @@
|
|||||||
</div>
|
</div>
|
||||||
<i class="dropdown icon"></i>
|
<i class="dropdown icon"></i>
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
|
{{if .IsAdminPage}}
|
||||||
|
<a class="item" href="/">
|
||||||
|
<i class="chart area icon"></i>返回前台
|
||||||
|
</a>
|
||||||
|
{{else}}
|
||||||
|
<a class="item" href="/server">
|
||||||
|
<i class="terminal icon"></i>管理后台
|
||||||
|
</a>
|
||||||
|
{{end}}
|
||||||
<button class="item" onclick="showConfirm('确认注销?','注销后您必须重新登录才能使用',logout,{{.Admin.ID}})">
|
<button class="item" onclick="showConfirm('确认注销?','注销后您必须重新登录才能使用',logout,{{.Admin.ID}})">
|
||||||
<i class="logout icon"></i>注销登录
|
<i class="logout icon"></i>注销登录
|
||||||
</button>
|
</button>
|
||||||
|
Loading…
Reference in New Issue
Block a user