From 9b3f1f3155264e4cc10137684b467c8e93c0508b Mon Sep 17 00:00:00 2001 From: taoshihan1991 <630892807@qq.com> Date: Wed, 17 Jun 2020 10:58:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/auth.go | 8 ++++++++ controller/chat.go | 2 +- controller/mysql.go | 1 + server.go | 2 ++ static/html/login.html | 3 +++ static/html/main.html | 2 +- static/html/nav.html | 2 +- 7 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 controller/mysql.go diff --git a/controller/auth.go b/controller/auth.go index 09d4595..d3c931c 100644 --- a/controller/auth.go +++ b/controller/auth.go @@ -6,6 +6,13 @@ import ( ) func AuthLocal(username string,password string)string{ account:=config.GetAccount() + if account==nil{ + account=make(map[string]string) + } + if account["Username"]=="" && account["Password"]==""{ + account["Username"]="admin" + account["Password"]="admin123" + } if username==account["Username"] && password==account["Password"]{ sessionId:=tools.Md5(username) @@ -19,6 +26,7 @@ func AuthLocal(username string,password string)string{ //验证是否已经登录 func AuthCheck(uid string)map[string]string{ info:=config.GetUserInfo(uid) + return info } diff --git a/controller/chat.go b/controller/chat.go index 7de7b93..0e73ba3 100644 --- a/controller/chat.go +++ b/controller/chat.go @@ -227,7 +227,7 @@ func sendPingToClient(){ } go func() { for{ - log.Println(2) + log.Println("check online users...") str,_:=json.Marshal(msg);sendStr:=string(str) for uid, conn := range clientList { err:=websocket.Message.Send(conn,sendStr) diff --git a/controller/mysql.go b/controller/mysql.go new file mode 100644 index 0000000..b0b429f --- /dev/null +++ b/controller/mysql.go @@ -0,0 +1 @@ +package controller diff --git a/server.go b/server.go index faddd23..0d2e801 100644 --- a/server.go +++ b/server.go @@ -47,6 +47,8 @@ func main() { mux.Handle("/chat_server",websocket.Handler(controller.ChatServer)) //获取在线用户 mux.HandleFunc("/chat_users", controller.ChatUsers) + //设置mysql + mux.HandleFunc("/setting_mysql",controller.ActionChatPage) //后台任务 controller.TimerSessFile() //监听端口 diff --git a/static/html/login.html b/static/html/login.html index 4914bfa..18cae34 100644 --- a/static/html/login.html +++ b/static/html/login.html @@ -227,6 +227,9 @@ }, }, created: function () { + if (top.location != location){ + top.location.href = location.href; + } } }) diff --git a/static/html/main.html b/static/html/main.html index ebe65c2..4721f6a 100644 --- a/static/html/main.html +++ b/static/html/main.html @@ -64,7 +64,7 @@ el: '#app', delimiters:["<{","}>"], data: { - iframeUrl:"/setting", + iframeUrl:"/chat_main", mailTotal:0, }, methods: { diff --git a/static/html/nav.html b/static/html/nav.html index 6a42a8f..49f905a 100644 --- a/static/html/nav.html +++ b/static/html/nav.html @@ -1,5 +1,5 @@ 邮箱