From b72d831df902f1f81c2d5f2f8868466063952251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B?= <994041296@163.com> Date: Thu, 12 Jan 2023 16:48:31 +0800 Subject: [PATCH] =?UTF-8?q?im=E5=95=86=E5=93=81=E8=B7=B3=E8=BD=AC=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/mine/im/index.vue | 1671 +++++++++++++++++++-------------------- utils/socket_service.js | 13 +- 2 files changed, 840 insertions(+), 844 deletions(-) diff --git a/pages/mine/im/index.vue b/pages/mine/im/index.vue index 2c59ef7..164779b 100644 --- a/pages/mine/im/index.vue +++ b/pages/mine/im/index.vue @@ -1,918 +1,915 @@ diff --git a/utils/socket_service.js b/utils/socket_service.js index be5a45d..73c691a 100644 --- a/utils/socket_service.js +++ b/utils/socket_service.js @@ -6,7 +6,7 @@ export default class SocketService { * 单例 */ static instance = null; - static get Instance() { + static get Instance () { if (!this.instance) { this.instance = new SocketService(); } @@ -29,12 +29,12 @@ export default class SocketService { connectRetryCount = 0; // 定义连接服务器的方法 - connect() { + connect () { // 连接服务器 if (!window.WebSocket) { return console.log("您的浏览器不支持WebSocket"); } - this.ws = new WebSocket(config.baseWsUrl+'/'+storage.getAccessToken()); + this.ws = new WebSocket(config.baseWsUrl + '/' + storage.getAccessToken()); // 连接成功的事件 this.ws.onopen = () => { console.log("连接服务端成功"); @@ -54,24 +54,23 @@ export default class SocketService { }; // 得到服务端发送过来的数据 this.ws.onmessage = (msg) => { - // console.log(msg.data) this.registerCallBack(msg.data); }; } // 回调函数的注册 - registerCallBack(callBack) { + registerCallBack (callBack) { // console.log("回调函数的注册", callBack); this.callBackMapping = callBack; } // 取消某一个回调函数 - unRegisterCallBack(callBack) { + unRegisterCallBack (callBack) { console.log("取消某一个回调函数", callBack); this.callBackMapping = null; } // 发送数据的方法 - send(data) { + send (data) { // 判断此时此刻有没有连接成功 if (this.connected) { this.sendRetryCount = 0;