fix:预警设置修改,巡检任务修改
This commit is contained in:
@@ -4,6 +4,10 @@ import modal from "./modal";
|
||||
class WebSocketService {
|
||||
constructor() {
|
||||
this.ws = null;
|
||||
// // 记录重连次数
|
||||
// this.reconnectCount = 0;
|
||||
// // 最大重连次数
|
||||
// this.maxReconnectAttempts = 2;
|
||||
this.reconnectInterval = 3000;
|
||||
this.eventListeners = {};
|
||||
}
|
||||
@@ -26,10 +30,23 @@ class WebSocketService {
|
||||
};
|
||||
|
||||
this.ws.onerror = (error) => {
|
||||
console.error("WebSocket error:", error);
|
||||
// console.error("WebSocket error:", error);
|
||||
this.emit("error", error);
|
||||
};
|
||||
|
||||
// this.ws.onclose = () => {
|
||||
// console.log("WebSocket closed");
|
||||
// this.emit("close");
|
||||
|
||||
// if (this.reconnectCount < this.maxReconnectAttempts) {
|
||||
// this.reconnectCount++;
|
||||
// console.log(`尝试第 ${this.reconnectCount} 次重连`);
|
||||
// setTimeout(() => this.connect(url), this.reconnectInterval);
|
||||
// } else {
|
||||
// console.log("达到最大重连次数,停止重连");
|
||||
// modal.msgError("WebSocket连接失败,请检查网络后刷新页面重试");
|
||||
// }
|
||||
// };
|
||||
this.ws.onclose = () => {
|
||||
console.log("WebSocket closed");
|
||||
this.emit("close");
|
||||
|
||||
Reference in New Issue
Block a user