From d1ecb3ea220013a2fb2a832eda98a718f2f54b89 Mon Sep 17 00:00:00 2001 From: guoapeng Date: Thu, 6 Mar 2025 04:32:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=87=8D=E8=BF=9E=E6=9C=BA=E5=88=B6?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/HeaderBar.vue | 4 +++- src/services/socket.ts | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/HeaderBar.vue b/src/components/HeaderBar.vue index 0c46474..5a9d5b2 100644 --- a/src/components/HeaderBar.vue +++ b/src/components/HeaderBar.vue @@ -48,11 +48,13 @@ import { createWebSocket, sharedWsUrl } from "@/services/socket"; const route = useRoute(); const router = useRouter(); -const isWifiNormal = ref(true); +const isWifiNormal = ref(false); onMounted(() => { const wsClient = createWebSocket(sharedWsUrl); + console.log(23333333) const subscription = wsClient.stateOb.subscribe(state => { + console.log(state); isWifiNormal.value = state === "open"; }); onUnmounted(() => { diff --git a/src/services/socket.ts b/src/services/socket.ts index 3812a2d..66abff5 100644 --- a/src/services/socket.ts +++ b/src/services/socket.ts @@ -82,11 +82,11 @@ class WebSocketClient { if (this.reconnectAttempts === -1) { this.reconnectAttempts = 0; } - if (this.reconnectAttempts >= this.maxReconnectAttempts) { - console.log("达到最大重连次数,停止重连"); - this.reconnectAttempts = -1; - return; - } + // if (this.reconnectAttempts >= this.maxReconnectAttempts) { + // console.log("达到最大重连次数,停止重连"); + // this.reconnectAttempts = -1; + // return; + // } setTimeout(() => { console.log(`尝试第 ${this.reconnectAttempts + 1} 次重连...`);