fix: 修复销毁websocket后还有心跳检测的问题
This commit is contained in:
@@ -388,6 +388,7 @@ const initHandler = () => {
|
||||
if (!appStore.hasToken) return;
|
||||
loadRecentConversation();
|
||||
///loadConversationMsgList();
|
||||
initTypewriterManager();
|
||||
initWebSocket();
|
||||
};
|
||||
|
||||
@@ -395,8 +396,6 @@ onMounted(() => {
|
||||
try {
|
||||
getMainPageData();
|
||||
addNoticeListener();
|
||||
initTypewriterManager();
|
||||
|
||||
// 有token时,加载最近会话、最近消息、初始化socket
|
||||
initHandler();
|
||||
} catch (error) {
|
||||
|
||||
@@ -121,8 +121,7 @@ export class WebSocketManager {
|
||||
this.connectionState = false;
|
||||
this._safeCallCallback("onError", {
|
||||
type: "CONNECTION_ERROR",
|
||||
message:
|
||||
"uni.connectSocket返回的SocketTask对象无效",
|
||||
message: "uni.connectSocket返回的SocketTask对象无效",
|
||||
originalError: null,
|
||||
});
|
||||
this.scheduleReconnect();
|
||||
@@ -427,9 +426,7 @@ export class WebSocketManager {
|
||||
}
|
||||
|
||||
if (this.reconnectAttempts >= this.maxReconnectAttempts) {
|
||||
console.error(
|
||||
`达到最大重连次数(${this.maxReconnectAttempts}),停止重连`
|
||||
);
|
||||
console.error(`达到最大重连次数(${this.maxReconnectAttempts}),停止重连`);
|
||||
this.connectionState = false;
|
||||
this.isConnecting = false;
|
||||
|
||||
@@ -573,6 +570,7 @@ export class WebSocketManager {
|
||||
*/
|
||||
close() {
|
||||
this.stopHeartbeat();
|
||||
this.resetConnectionState();
|
||||
|
||||
// 清理重连定时器
|
||||
TimerUtils.clearTimer(this.reconnectTimer);
|
||||
|
||||
Reference in New Issue
Block a user