From 2b8ad5a5fecf29fcd3aacc8083ad6928cf451131 Mon Sep 17 00:00:00 2001 From: ywyonui Date: Sat, 6 Sep 2025 10:19:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=98=E5=8E=9Fwebsocket=E6=96=AD=E5=BC=80?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E7=9A=84=E6=8F=90=E7=A4=BA=EF=BC=8C=E4=B8=80?= =?UTF-8?q?=E7=9B=B4=E6=98=BE=E7=A4=BA=E6=96=AD=E5=BC=80=E9=87=8D=E8=BF=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/webSocket/webSocket.ts | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/utils/webSocket/webSocket.ts b/src/utils/webSocket/webSocket.ts index 6d000d2..2843cf7 100644 --- a/src/utils/webSocket/webSocket.ts +++ b/src/utils/webSocket/webSocket.ts @@ -1,4 +1,5 @@ import { BASE_WS_URL } from "@/config"; +import { hideLoading, showLoading } from "@/utils/uniapp"; export interface WebSocketReturn { reconnect: () => void, @@ -10,25 +11,13 @@ let isLoading = false function heartbeatState(state: boolean) { if (!state) { - if (isLoading) { - // 使用顶部提示代替中间loading - uni.showToast({ - title: '网络异常,重新连接中...', - icon: 'none', - position: 'top', - duration: 2000 - }); + if (!isLoading) { + showLoading({ title: '网络异常,重新连接中' }) } isLoading = true } - if (state && isLoading) { - // 隐藏提示 - uni.showToast({ - title: '连接已恢复', - icon: 'success', - position: 'top', - duration: 1000 - }); + if (state) { + hideLoading() isLoading = false } }