还原websocket断开链接的提示,一直显示断开重连
This commit is contained in:
parent
7b2ac02adb
commit
2b8ad5a5fe
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user