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 } }