mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
parent
345511e90f
commit
1c2cc5dcab
@ -67,29 +67,20 @@ func (p *commonPage) service(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
u, ok := c.Get(model.CtxKeyAuthorizedUser)
|
||||
data := mygin.CommonEnvironment(c, gin.H{
|
||||
c.HTML(http.StatusOK, "theme-"+dao.Conf.Site.Theme+"/service", mygin.CommonEnvironment(c, gin.H{
|
||||
"Title": "服务状态",
|
||||
"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) {
|
||||
dao.ServerLock.RLock()
|
||||
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,
|
||||
"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{}
|
||||
|
@ -10,9 +10,18 @@ import (
|
||||
"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 {
|
||||
data["MatchedPath"] = c.MustGet("MatchedPath")
|
||||
data["Version"] = dao.Version
|
||||
// 是否是管理页面
|
||||
data["IsAdminPage"] = adminPage[data["MatchedPath"].(string)]
|
||||
// 站点标题
|
||||
if t, has := data["Title"]; !has {
|
||||
data["Title"] = dao.Conf.Site.Brand
|
||||
|
@ -4,13 +4,14 @@
|
||||
<div class="item">
|
||||
<img src="/static/logo.png">
|
||||
</div>
|
||||
<a class="item{{if eq .MatchedPath " /"}} active{{end}}" href="/">首页</a>
|
||||
<a class="item{{if eq .MatchedPath " /service"}} active{{end}}" href="/service">服务状态</a>
|
||||
{{if .Admin}}
|
||||
{{if .IsAdminPage}}
|
||||
<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 " /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}}
|
||||
<div class="right menu">
|
||||
<div class="item">
|
||||
@ -21,6 +22,15 @@
|
||||
</div>
|
||||
<i class="dropdown icon"></i>
|
||||
<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}})">
|
||||
<i class="logout icon"></i>注销登录
|
||||
</button>
|
||||
|
Loading…
Reference in New Issue
Block a user