websocket逻辑优化

This commit is contained in:
kron
2025-07-18 13:38:01 +08:00
parent ccfd09bb01
commit 4f4178b75d
3 changed files with 42 additions and 41 deletions

View File

@@ -13,6 +13,7 @@ export const checkConnection = () => {
uni.sendSocketMessage({
data: JSON.stringify({ event: "ping", data: {} }),
fail: () => {
websocket.closeWebSocket();
const token = uni.getStorageSync("token");
if (!token) return;
// 如果发送失败,说明连接已断开,需要重新连接