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} 次重连...`);