地图实时显示无人机和机器经纬度
This commit is contained in:
@@ -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 = {};
|
||||
|
||||
Reference in New Issue
Block a user