From 3c86c4561a79553227959081e9ba5e51b6f6233f Mon Sep 17 00:00:00 2001 From: linxi Date: Mon, 21 Apr 2025 14:32:36 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A3648=20=E3=80=90=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E3=80=91=E8=BF=9B=E5=85=A5=E5=AE=A2?= =?UTF-8?q?=E6=9C=8D=E4=BC=9A=E8=AF=9D=E9=A1=B5=E9=9D=A2=E5=B9=B6=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=90=8E=EF=BC=8C=E5=86=8D=E6=AC=A1=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E6=9C=AA=E6=98=BE=E7=A4=BA=E6=B6=88=E6=81=AF=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg_common/views/room.vue | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg_common/views/room.vue b/pkg_common/views/room.vue index 95d81ee..9238697 100644 --- a/pkg_common/views/room.vue +++ b/pkg_common/views/room.vue @@ -132,13 +132,19 @@ export default { this.token = uni.getStorageSync("login_status"); this.userInfo = uni.getStorageSync("userInfo"); this.uid = this.userInfo.uid - this.content = uni.getStorageSync(this.merName+this.uid+this.storeId) - this.connectSocketInit() + }, - onHide() { + onShow() { + this.content = uni.getStorageSync(this.merName+this.uid+this.storeId) + this.connectSocketInit(); + }, + onUnload() { if (this.socketOpen) { this.socketTask.close(); } + uni.onSocketClose(res => { + console.log('WebSocket 已关闭!', res); + }); uni.setStorageSync(this.merName+this.uid+this.storeId, this.content) }, methods: { @@ -247,7 +253,6 @@ export default { console.log('WebSocket连接已打开!', res); this.socketOpen = true; this.createRoom(); - }); uni.onSocketError(err => {