页面隐藏 断websocket 修改map中points的数据结构
This commit is contained in:
@@ -479,7 +479,6 @@ export default function DeviceStatusPage({
|
||||
: 'robot',
|
||||
};
|
||||
}, [device, isUAV, runningStatus, uavState, currentDroneData]);
|
||||
console.log('DeviceStatusPage mapDevices:', mapDevices);
|
||||
const realtimeDevice = useMemo(() => {
|
||||
if (!device) return null;
|
||||
return {
|
||||
|
||||
@@ -65,7 +65,7 @@ const DroneVideoPlayer: React.FC<DroneVideoPlayerProps> = ({
|
||||
cameraIndex,
|
||||
cameraPosition,
|
||||
qualityType: "adaptive",
|
||||
videoExpire: 7200,
|
||||
videoExpire: 720000000,
|
||||
});
|
||||
|
||||
if (res.code == 200) setStationStreamData(res.data);
|
||||
@@ -100,7 +100,7 @@ const DroneVideoPlayer: React.FC<DroneVideoPlayerProps> = ({
|
||||
lensType,
|
||||
cameraIndex,
|
||||
qualityType: "adaptive",
|
||||
videoExpire: 7200,
|
||||
videoExpire: 720000000,
|
||||
});
|
||||
|
||||
if (res.code === 200) setDroneStreamData(res.data);
|
||||
|
||||
@@ -597,7 +597,7 @@ export default function WayLinePage({ onRefresh }) {
|
||||
const res = await getsinglePlanTrack(record);
|
||||
if (res.code === 0 && res.data.track?.points?.length) {
|
||||
const points = res.data.track.points.map(item => ({
|
||||
lon: item.longitude || item.lon,
|
||||
lng: item.longitude || item.lon,
|
||||
lat: item.latitude || item.lat
|
||||
}));
|
||||
setPoints(points);
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user