还原websocket断开链接的提示,一直显示断开重连
This commit is contained in:
parent
7b2ac02adb
commit
2b8ad5a5fe
@ -1,4 +1,5 @@
|
|||||||
import { BASE_WS_URL } from "@/config";
|
import { BASE_WS_URL } from "@/config";
|
||||||
|
import { hideLoading, showLoading } from "@/utils/uniapp";
|
||||||
|
|
||||||
export interface WebSocketReturn {
|
export interface WebSocketReturn {
|
||||||
reconnect: () => void,
|
reconnect: () => void,
|
||||||
@ -10,25 +11,13 @@ let isLoading = false
|
|||||||
|
|
||||||
function heartbeatState(state: boolean) {
|
function heartbeatState(state: boolean) {
|
||||||
if (!state) {
|
if (!state) {
|
||||||
if (isLoading) {
|
if (!isLoading) {
|
||||||
// 使用顶部提示代替中间loading
|
showLoading({ title: '网络异常,重新连接中' })
|
||||||
uni.showToast({
|
|
||||||
title: '网络异常,重新连接中...',
|
|
||||||
icon: 'none',
|
|
||||||
position: 'top',
|
|
||||||
duration: 2000
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
isLoading = true
|
isLoading = true
|
||||||
}
|
}
|
||||||
if (state && isLoading) {
|
if (state) {
|
||||||
// 隐藏提示
|
hideLoading()
|
||||||
uni.showToast({
|
|
||||||
title: '连接已恢复',
|
|
||||||
icon: 'success',
|
|
||||||
position: 'top',
|
|
||||||
duration: 1000
|
|
||||||
});
|
|
||||||
isLoading = false
|
isLoading = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user