From 463250a2e74b80dc62a1e46e6fe390ec8bf2b54e Mon Sep 17 00:00:00 2001 From: luohairen <3399054449@qq.com> Date: 星期四, 31 十月 2024 19:06:43 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/hooks/useWebScoket.js | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/hooks/useWebScoket.js b/src/hooks/useWebScoket.js index 5f3da78..bfa22e2 100644 --- a/src/hooks/useWebScoket.js +++ b/src/hooks/useWebScoket.js @@ -54,7 +54,7 @@ status.value = SocketStatus.Connected; error.value = null; startHeartBeat(); - if(connectCallBack) { + if (connectCallBack) { connectCallBack(); } }; @@ -172,11 +172,12 @@ }; onBeforeUnmount(() => { - if (status.value === SocketStatus.Connected || status.value === SocketStatus.Connecting) { - disconnect(); - } + disconnect(); }); + window.addEventListener('unload', () => { + disconnect(); + }); return { status, message, -- Gitblit v1.8.0