页面隐藏 断websocket 修改map中points的数据结构
This commit is contained in:
@@ -189,9 +189,10 @@ export default function CesiumMap({ realtimePosition, realtimeType, pathPoints =
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(points, "4324345")
|
||||
const validPoints = points.filter(p => {
|
||||
const lon = Number(p.lon);
|
||||
|
||||
const lon = Number(p.lng);
|
||||
const lat = Number(p.lat);
|
||||
return (
|
||||
!isNaN(lon) &&
|
||||
@@ -207,7 +208,7 @@ export default function CesiumMap({ realtimePosition, realtimeType, pathPoints =
|
||||
|
||||
const positions = validPoints.map(point =>
|
||||
Cesium.Cartesian3.fromDegrees(
|
||||
Number(point.lon),
|
||||
Number(point.lng),
|
||||
Number(point.lat)
|
||||
)
|
||||
);
|
||||
@@ -235,8 +236,8 @@ export default function CesiumMap({ realtimePosition, realtimeType, pathPoints =
|
||||
let minLat = 90, maxLat = -90;
|
||||
|
||||
validPoints.forEach(p => {
|
||||
minLon = Math.min(minLon, p.lon);
|
||||
maxLon = Math.max(maxLon, p.lon);
|
||||
minLon = Math.min(minLon, p.lng);
|
||||
maxLon = Math.max(maxLon, p.lng);
|
||||
minLat = Math.min(minLat, p.lat);
|
||||
maxLat = Math.max(maxLat, p.lat);
|
||||
});
|
||||
@@ -251,7 +252,7 @@ export default function CesiumMap({ realtimePosition, realtimeType, pathPoints =
|
||||
viewer.scene.requestRender();
|
||||
viewer.camera.flyTo({
|
||||
destination: Cesium.Cartesian3.fromDegrees(
|
||||
p.lon,
|
||||
p.lng,
|
||||
p.lat,
|
||||
800
|
||||
),
|
||||
|
||||
@@ -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