去除websocket链接错误失败时的弹窗

This commit is contained in:
2025-02-24 14:17:06 +08:00
parent 7489a9cc39
commit 2d53c6ee0f
4 changed files with 683 additions and 22 deletions

View File

@@ -58,19 +58,17 @@ class WebSocketManager {
this.client.onopen = () => {
this.connected = true;
console.log("WebSocket 连接已建立");
ElNotification.success('WebSocket 连接已建立')
// ElNotification.success('WebSocket 连接已建立')
this.sendMessage(this.initParams)
};
this.client.onclose = () => {
if (!this.connected) {
ElMessageBox.alert('WebSocket 连接已断开', 'Title', {
// if you want to disable its autofocus
// autofocus: false,
confirmButtonText: '立即重连',
callback: () => {
this.sendMessage(this.initParams)
},
})
// ElMessageBox.alert('WebSocket 连接已断开', 'Title', {
// confirmButtonText: '立即重连',
// callback: () => {
// this.sendMessage(this.initParams)
// },
// })
}
this.connected = false;
console.log("WebSocket 连接已断开");
@@ -78,19 +76,17 @@ class WebSocketManager {
};
this.client.onerror = (error) => {
console.error("WebSocket 发生错误:", error);
ElNotification({
title: "提示",
message: "WebSocket 发生错误",
type: "error",
});
ElMessageBox.alert('WebSocket 发生错误', 'Title', {
// if you want to disable its autofocus
// autofocus: false,
confirmButtonText: '立即重连',
callback: () => {
this.sendMessage(this.initParams)
},
})
// ElNotification({
// title: "提示",
// message: "WebSocket 发生错误",
// type: "error",
// });
// ElMessageBox.alert('WebSocket 发生错误', 'Title', {
// confirmButtonText: '立即重连',
// callback: () => {
// this.sendMessage(this.initParams)
// },
// })
};
this.client.onmessage = (event) => {
const message = event.data;