From 2103cd1f59b04d567ee888e10ab9243a9129b119 Mon Sep 17 00:00:00 2001 From: taoshihan1991 <630892807@qq.com> Date: Tue, 21 Jul 2020 16:39:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BF=83=E8=B7=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/chat.go | 10 +++++++++- main.go | 4 ++-- models/roles.go | 2 ++ static/html/chat_main.html | 14 ++++++++++++++ static/html/chat_page.html | 14 ++++++++++++++ static/html/nav.html | 2 +- static/html/setting_left.html | 4 ++-- static/html/setting_role_list.html | 4 ++++ 8 files changed, 48 insertions(+), 6 deletions(-) diff --git a/controller/chat.go b/controller/chat.go index 6bcaf3b..2166770 100644 --- a/controller/chat.go +++ b/controller/chat.go @@ -136,7 +136,7 @@ func sendPingToClient() { delete(kefuList, kefuId) } } - time.Sleep(5 * time.Second) + time.Sleep(15 * time.Second) } }() @@ -291,7 +291,15 @@ func singleBroadcaster(){ } str, _ := json.Marshal(msg) conn.WriteMessage(websocket.TextMessage,str) + //心跳 + case "ping": + msg := TypeMessage{ + Type: "pong", + } + str, _ := json.Marshal(msg) + conn.WriteMessage(websocket.TextMessage,str) } + } } diff --git a/main.go b/main.go index aa65b3f..c73e2ad 100644 --- a/main.go +++ b/main.go @@ -57,7 +57,7 @@ func main() { //设置mysql engine.GET("/setting_mysql", tmpl.PageSettingMysql) //角色列表 - engine.GET("/roles", controller.GetRoleList) + engine.GET("/roles",middleware.JwtApiMiddleware, controller.GetRoleList) engine.GET("/roles_list", tmpl.PageRoleList) //网页部署 @@ -82,7 +82,7 @@ func main() { //文档服务 docs.SwaggerInfo.Title = "GO-FLY接口文档" docs.SwaggerInfo.Description = "go-fly即时通讯web客服管理系统 , 测试账户:kefu2 测试密码:123 类型:kefu" - docs.SwaggerInfo.Version = "0.0.6" + docs.SwaggerInfo.Version = "0.0.7" //docs.SwaggerInfo.Host = "127.0.0.1:"+port docs.SwaggerInfo.Host = "gofly.sopans.com" docs.SwaggerInfo.BasePath = "/" diff --git a/models/roles.go b/models/roles.go index 7d7654c..2b1e54f 100644 --- a/models/roles.go +++ b/models/roles.go @@ -2,6 +2,8 @@ package models type Role struct{ Id string `json:"role_id"` Name string `json:"role_name"` + Method string `json:"method"` + Path string `json:"path"` } func FindRoles()[]Role{ var roles []Role diff --git a/static/html/chat_main.html b/static/html/chat_main.html index c5d8e1f..aad30f4 100644 --- a/static/html/chat_main.html +++ b/static/html/chat_main.html @@ -201,6 +201,18 @@ mes.data = this.kfConfig; this.socket.send(JSON.stringify(mes)); }, + //心跳 + ping(){ + let _this=this; + let mes = {} + mes.type = "ping"; + mes.data = ""; + setInterval(function () { + if(_this.socket!=null){ + _this.socket.send(JSON.stringify(mes)); + } + },5000) + }, //初始化websocket initConn() { let socket = new ReconnectingWebSocket(this.server);//创建Socket实例 @@ -487,6 +499,8 @@ }, created: function () { this.getKefuInfo(); + //心跳 + this.ping(); } }) diff --git a/static/html/chat_page.html b/static/html/chat_page.html index ae50e26..04cc48a 100644 --- a/static/html/chat_page.html +++ b/static/html/chat_page.html @@ -319,6 +319,18 @@ $(".chatBox").css("max-height",$(window).height()); }); }, + //心跳 + ping(){ + let _this=this; + let mes = {} + mes.type = "ping"; + mes.data = ""; + setInterval(function () { + if(_this.socket!=null){ + _this.socket.send(JSON.stringify(mes)); + } + },5000); + }, }, created: function () { @@ -330,6 +342,8 @@ this.scrollBottom(); //获取欢迎 this.getNotice(); + //心跳 + this.ping(); } }) diff --git a/static/html/nav.html b/static/html/nav.html index e8d96ec..7117af3 100644 --- a/static/html/nav.html +++ b/static/html/nav.html @@ -2,7 +2,7 @@ - + 邮箱 聊天 diff --git a/static/html/setting_left.html b/static/html/setting_left.html index c03b7f5..e9ac652 100644 --- a/static/html/setting_left.html +++ b/static/html/setting_left.html @@ -7,7 +7,7 @@ 智能回复 - 客服管理 + @@ -16,8 +16,8 @@ 权限设置 + 用户管理 角色管理 - 结点管理 diff --git a/static/html/setting_role_list.html b/static/html/setting_role_list.html index 66ff8ac..d42393b 100644 --- a/static/html/setting_role_list.html +++ b/static/html/setting_role_list.html @@ -16,6 +16,10 @@ prop="role_name" label="角色名称"> + +