feat: 代客下单优惠券更新,挂账更新
This commit is contained in:
@@ -38,7 +38,7 @@ class WebSocketManager {
|
||||
private reconnectAttempts = 0;
|
||||
private maxReconnectAttempts = 3; // 自定义最大重试次数
|
||||
private reconnectDelay = 5000; // 重试延迟(单位:毫秒)
|
||||
|
||||
private timer: any | null = null;
|
||||
// 初始化 WebSocket 客户端
|
||||
setupWebSocket() {
|
||||
const endpoint = import.meta.env.VITE_APP_WS_ENDPOINT;
|
||||
@@ -60,8 +60,13 @@ class WebSocketManager {
|
||||
console.log("WebSocket 连接已建立");
|
||||
// ElNotification.success('WebSocket 连接已建立')
|
||||
this.sendMessage(this.initParams)
|
||||
clearTimeout(this.timer)
|
||||
this.timer = setInterval(() => {
|
||||
this.sendMessage({ "type": "ping_interval" })
|
||||
}, 1000 * 10);
|
||||
};
|
||||
this.client.onclose = () => {
|
||||
clearTimeout(this.timer)
|
||||
if (!this.connected) {
|
||||
// ElMessageBox.alert('WebSocket 连接已断开', 'Title', {
|
||||
// confirmButtonText: '立即重连',
|
||||
@@ -74,6 +79,7 @@ class WebSocketManager {
|
||||
console.log("WebSocket 连接已断开");
|
||||
};
|
||||
this.client.onerror = (error) => {
|
||||
clearTimeout(this.timer)
|
||||
console.error("WebSocket 发生错误:", error);
|
||||
// ElNotification({
|
||||
// title: "提示",
|
||||
|
||||
Reference in New Issue
Block a user