🔖 [dashboard 0.9.17] 404 页面

This commit is contained in:
naiba 2021-08-10 20:13:17 +08:00
parent 985ecc7c65
commit c848b9a08b
7 changed files with 20 additions and 6 deletions

View File

@ -4,7 +4,7 @@
<br>
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
<br><br>
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.9.16&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github">&nbsp;<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/badge/Installer-v0.6.5-brightgreen?style=for-the-badge&logo=linux">
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.9.17&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github">&nbsp;<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/badge/Installer-v0.6.5-brightgreen?style=for-the-badge&logo=linux">
<br>
<br>
<p>:trollface: <b>哪吒监控</b> 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。</p>

View File

@ -45,6 +45,7 @@ func (p *commonPage) issueViewPassword(c *gin.Context) {
}
if err != nil {
mygin.ShowErrorPage(c, mygin.ErrInfo{
Code: http.StatusOK,
Title: "出现错误",
Msg: fmt.Sprintf("请求错误:%s", err),
}, true)

View File

@ -113,6 +113,19 @@ func ServeWeb(port uint) *http.Server {
r.Static("/static", "resource/static")
r.LoadHTMLGlob("resource/template/**/*")
routers(r)
page404 := func(c *gin.Context) {
mygin.ShowErrorPage(c, mygin.ErrInfo{
Code: http.StatusNotFound,
Title: "该页面不存在",
Msg: "该页面内容可能已着陆火星",
Link: "/",
Btn: "返回首页",
}, true)
}
r.NoRoute(page404)
r.NoMethod(page404)
srv := &http.Server{
Addr: fmt.Sprintf(":%d", port),
Handler: r,

View File

@ -14,7 +14,7 @@ type Common struct {
}
type Response struct {
Code uint64 `json:"code,omitempty"`
Code int `json:"code,omitempty"`
Message string `json:"message,omitempty"`
Result interface{} `json:"result,omitempty"`
}

View File

@ -22,7 +22,7 @@ type AuthorizeOption struct {
func Authorize(opt AuthorizeOption) func(*gin.Context) {
return func(c *gin.Context) {
var code uint64 = http.StatusForbidden
var code = http.StatusForbidden
if opt.Guest {
code = http.StatusBadRequest
}

View File

@ -9,7 +9,7 @@ import (
)
type ErrInfo struct {
Code uint64
Code int
Title string
Msg string
Link string
@ -18,7 +18,7 @@ type ErrInfo struct {
func ShowErrorPage(c *gin.Context, i ErrInfo, isPage bool) {
if isPage {
c.HTML(http.StatusOK, "dashboard/error", CommonEnvironment(c, gin.H{
c.HTML(i.Code, "dashboard/error", CommonEnvironment(c, gin.H{
"Code": i.Code,
"Title": i.Title,
"Msg": i.Msg,

View File

@ -13,7 +13,7 @@ import (
pb "github.com/naiba/nezha/proto"
)
var Version = "v0.9.16" // !!记得修改 README 中的 badge 版本!!
var Version = "v0.9.17" // !!记得修改 README 中的 badge 版本!!
var (
Conf *model.Config