地图实时显示无人机和机器经纬度

This commit is contained in:
mmc
2026-06-02 13:03:40 +08:00
parent c4a9ac4ea4
commit d1dd2b4c70
2 changed files with 41 additions and 14 deletions

View File

@@ -62,6 +62,7 @@ export default class DeviceController {
// ========== 【集成】页面切前台重连 ==========
handleVisibilityChange() {
if (document.visibilityState === 'visible' && this.currentDevice) {
if (!this.currentDevice?.serialNumber) return;
console.log('✅ 页面切回前台,自动重连 WebSocket');
setTimeout(() => {
this.connectDevice(this.currentDevice);
@@ -75,7 +76,7 @@ export default class DeviceController {
if (
this.connectedDeviceSn &&
this.wsStatus !== 'connected' &&
this.currentDevice
this.currentDevice?.serialNumber
) {
console.log('🔄 后台保活:尝试重连 WebSocket');
this.connectDevice(this.currentDevice);
@@ -116,8 +117,9 @@ export default class DeviceController {
// 保存当前设备,用于保活/重连
this.currentDevice = device;
if (!device.serialNumber) return;
const sn = device.serialNumber || device.device_sn;
const sn = device.serialNumber;
this.connectedDeviceSn = null;
this.wsDeviceInfo = {};