From 796ae971e778727e377b205c4430205cb3578af6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B6=E5=A3=AB=E6=B6=B5?= <630892807@qq.com> Date: Tue, 23 Feb 2021 23:08:58 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B2=E6=AD=A2=E5=A4=9A=E6=AC=A1=E9=87=8D?= =?UTF-8?q?=E8=BF=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/js/chat-page.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/static/js/chat-page.js b/static/js/chat-page.js index 452fbb6..28040e6 100644 --- a/static/js/chat-page.js +++ b/static/js/chat-page.js @@ -16,10 +16,12 @@ new Vue({ timer:null, sendDisabled:false, flyLang:GOFLY_LANG[LANG], + connecting:true, }, methods: { //初始化websocket initConn:function() { + this.connecting=true; let socket = new ReconnectingWebSocket(this.server+"?visitor_id="+this.visitor.visitor_id);//创建Socket实例 socket.maxReconnectAttempts = 30; this.socket = socket @@ -31,6 +33,8 @@ new Vue({ }, OnOpen:function() { this.chatTitle=GOFLY_LANG[LANG]['connectok']; + this.connecting=false; + }, OnMessage:function(e) { const redata = JSON.parse(e.data); @@ -357,6 +361,9 @@ new Vue({ $('.faceBox').hide(); }); window.onfocus = function () { + if(_this.connecting=true){ + return; + } _this.initConn(); } },