From e0b23044a478fa34f6deb297378b701d9adfc0bc Mon Sep 17 00:00:00 2001 From: taoshihan Date: Tue, 22 Jul 2025 23:07:38 +0800 Subject: [PATCH] code review --- controller/main.go | 13 +------------ router/api.go | 2 +- static/templates/main.html | 5 ++--- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/controller/main.go b/controller/main.go index 3b1e56c..c81f1e5 100644 --- a/controller/main.go +++ b/controller/main.go @@ -95,18 +95,7 @@ func install() (bool, error) { } return true, nil } -func MainCheckAuth(c *gin.Context) { - kefuName, _ := c.Get("kefu_name") - userinfo := models.FindUser(kefuName.(string)) - c.JSON(200, gin.H{ - "code": 200, - "msg": "验证成功", - "result": gin.H{ - "avator": userinfo.Avator, - "name": userinfo.Name, - }, - }) -} + func GetStatistics(c *gin.Context) { visitors := models.CountVisitors() message := models.CountMessage(nil, nil) diff --git a/router/api.go b/router/api.go index 6bef30d..86cad40 100644 --- a/router/api.go +++ b/router/api.go @@ -22,7 +22,7 @@ func InitApiRouter(engine *gin.Engine) { } engine.GET("/captcha", controller.GetCaptcha) engine.POST("/check", controller.LoginCheckPass) - engine.POST("/check_auth", middleware.JwtApiMiddleware, controller.MainCheckAuth) + engine.GET("/userinfo", middleware.JwtApiMiddleware, controller.GetKefuInfoAll) engine.POST("/register", middleware.Ipblack, controller.PostKefuRegister) engine.POST("/install", controller.PostInstall) diff --git a/static/templates/main.html b/static/templates/main.html index dab87e8..3a4850d 100644 --- a/static/templates/main.html +++ b/static/templates/main.html @@ -137,8 +137,8 @@ checkAuth(){ let _this=this; $.ajax({ - type:"post", - url:"/check_auth", + type:"GET", + url:"/kefuinfo", headers:{ "token":localStorage.getItem("token") }, @@ -147,7 +147,6 @@ window.location.href="/login"; } else { _this.adminAvator=data.result.avator; - _this.adminRole=data.result.role_name; _this.iframeUrl = "/pannel"; } }