diff --git a/src/apis/map/constant.ts b/src/apis/map/constant.ts index 0b143f3..f092111 100644 --- a/src/apis/map/constant.ts +++ b/src/apis/map/constant.ts @@ -133,8 +133,8 @@ export const EDITOR_CONFIG: Options = { disableEmptyLine: true, /** 禁用重复线条 - 不允许在同一对点之间创建多条线 */ disableRepeatLine: true, - /** 最小缩放比例 - 画布最小缩放到24% */ - minScale: 0.24, + /** 最小缩放比例 - 画布最小缩放到1% */ + minScale: 0.01, /** 最大缩放比例 - 画布最大缩放到401% */ maxScale: 4.01, /** 缩放步长 - 每次滚轮滚动的缩放幅度(5%) */ diff --git a/src/services/ws.ts b/src/services/ws.ts index bb0c2d8..aa5ad94 100644 --- a/src/services/ws.ts +++ b/src/services/ws.ts @@ -1,10 +1,10 @@ // WebSocket全局配置 const WS_CONFIG = { - heartbeatInterval: 30000, // 30秒心跳间隔 - heartbeatTimeout: 5000, // 心跳响应超时时间(5秒) + heartbeatInterval: 10000, // 30秒心跳间隔 + heartbeatTimeout: 10000, // 心跳响应超时时间(10秒,给服务器更多响应时间) maxReconnectAttempts: 5, // 最大重连次数 - reconnectBaseDelay: 1000, // 重连基础延迟1秒 - maxReconnectDelay: 30000, // 最大重连延迟30秒 + reconnectBaseDelay: 500, // 重连基础延迟0.5秒(更快重连) + maxReconnectDelay: 10000, // 最大重连延迟10秒(减少等待时间) heartbeatMessage: 'ping', // 心跳消息 heartbeatResponseType: 'pong', // 心跳响应类型 }; @@ -38,6 +38,12 @@ class EnhancedWebSocket { console.log(`WebSocket连接已建立: ${this.path}`); this.reconnectAttempts = 0; this.clearReconnectTimer(); + + // 🔧 优化:连接建立后立即发送一次心跳,然后开始定期心跳 + if (this.ws.readyState === WebSocket.OPEN) { + this.ws.send(WS_CONFIG.heartbeatMessage); + this.startHeartbeatTimeout(); + } this.startHeartbeat(); if (this.userOnOpen) { @@ -48,6 +54,9 @@ class EnhancedWebSocket { this.ws.onmessage = (event) => { const messageData = event.data; + // 🔧 优化:收到任何消息都说明连接正常,清除心跳超时检测 + this.clearHeartbeatTimeout(); + // 检查是否为心跳响应(支持字符串和JSON格式) let isHeartbeatResponse = false; @@ -69,8 +78,7 @@ class EnhancedWebSocket { } if (isHeartbeatResponse) { - // 收到心跳响应,清除超时定时器 - this.clearHeartbeatTimeout(); + // 心跳响应,不传递给业务代码 return; }