页面隐藏 断websocket 修改map中points的数据结构

This commit is contained in:
mmc
2026-06-04 11:49:20 +08:00
parent c66712c2e4
commit 84bcf11691
5 changed files with 18 additions and 10 deletions

View File

@@ -61,6 +61,14 @@ export default class DeviceController {
// ========== 【集成】页面切前台重连 ==========
handleVisibilityChange() {
// 切后台:关闭 WS
if (document.visibilityState === 'hidden') {
console.log('🔌 页面切后台,关闭 WebSocket');
wsManager.close();
this.isControlled = false;
this.onControlStatusChange?.(false);
}
if (document.visibilityState === 'visible' && this.currentDevice) {
if (!this.currentDevice?.serialNumber) return;
console.log('✅ 页面切回前台,自动重连 WebSocket');