页面隐藏 断websocket 修改map中points的数据结构
This commit is contained in:
@@ -189,9 +189,10 @@ export default function CesiumMap({ realtimePosition, realtimeType, pathPoints =
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.log(points, "4324345")
|
||||||
const validPoints = points.filter(p => {
|
const validPoints = points.filter(p => {
|
||||||
const lon = Number(p.lon);
|
|
||||||
|
const lon = Number(p.lng);
|
||||||
const lat = Number(p.lat);
|
const lat = Number(p.lat);
|
||||||
return (
|
return (
|
||||||
!isNaN(lon) &&
|
!isNaN(lon) &&
|
||||||
@@ -207,7 +208,7 @@ export default function CesiumMap({ realtimePosition, realtimeType, pathPoints =
|
|||||||
|
|
||||||
const positions = validPoints.map(point =>
|
const positions = validPoints.map(point =>
|
||||||
Cesium.Cartesian3.fromDegrees(
|
Cesium.Cartesian3.fromDegrees(
|
||||||
Number(point.lon),
|
Number(point.lng),
|
||||||
Number(point.lat)
|
Number(point.lat)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -235,8 +236,8 @@ export default function CesiumMap({ realtimePosition, realtimeType, pathPoints =
|
|||||||
let minLat = 90, maxLat = -90;
|
let minLat = 90, maxLat = -90;
|
||||||
|
|
||||||
validPoints.forEach(p => {
|
validPoints.forEach(p => {
|
||||||
minLon = Math.min(minLon, p.lon);
|
minLon = Math.min(minLon, p.lng);
|
||||||
maxLon = Math.max(maxLon, p.lon);
|
maxLon = Math.max(maxLon, p.lng);
|
||||||
minLat = Math.min(minLat, p.lat);
|
minLat = Math.min(minLat, p.lat);
|
||||||
maxLat = Math.max(maxLat, p.lat);
|
maxLat = Math.max(maxLat, p.lat);
|
||||||
});
|
});
|
||||||
@@ -251,7 +252,7 @@ export default function CesiumMap({ realtimePosition, realtimeType, pathPoints =
|
|||||||
viewer.scene.requestRender();
|
viewer.scene.requestRender();
|
||||||
viewer.camera.flyTo({
|
viewer.camera.flyTo({
|
||||||
destination: Cesium.Cartesian3.fromDegrees(
|
destination: Cesium.Cartesian3.fromDegrees(
|
||||||
p.lon,
|
p.lng,
|
||||||
p.lat,
|
p.lat,
|
||||||
800
|
800
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -479,7 +479,6 @@ export default function DeviceStatusPage({
|
|||||||
: 'robot',
|
: 'robot',
|
||||||
};
|
};
|
||||||
}, [device, isUAV, runningStatus, uavState, currentDroneData]);
|
}, [device, isUAV, runningStatus, uavState, currentDroneData]);
|
||||||
console.log('DeviceStatusPage mapDevices:', mapDevices);
|
|
||||||
const realtimeDevice = useMemo(() => {
|
const realtimeDevice = useMemo(() => {
|
||||||
if (!device) return null;
|
if (!device) return null;
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ const DroneVideoPlayer: React.FC<DroneVideoPlayerProps> = ({
|
|||||||
cameraIndex,
|
cameraIndex,
|
||||||
cameraPosition,
|
cameraPosition,
|
||||||
qualityType: "adaptive",
|
qualityType: "adaptive",
|
||||||
videoExpire: 7200,
|
videoExpire: 720000000,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.code == 200) setStationStreamData(res.data);
|
if (res.code == 200) setStationStreamData(res.data);
|
||||||
@@ -100,7 +100,7 @@ const DroneVideoPlayer: React.FC<DroneVideoPlayerProps> = ({
|
|||||||
lensType,
|
lensType,
|
||||||
cameraIndex,
|
cameraIndex,
|
||||||
qualityType: "adaptive",
|
qualityType: "adaptive",
|
||||||
videoExpire: 7200,
|
videoExpire: 720000000,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.code === 200) setDroneStreamData(res.data);
|
if (res.code === 200) setDroneStreamData(res.data);
|
||||||
|
|||||||
@@ -597,7 +597,7 @@ export default function WayLinePage({ onRefresh }) {
|
|||||||
const res = await getsinglePlanTrack(record);
|
const res = await getsinglePlanTrack(record);
|
||||||
if (res.code === 0 && res.data.track?.points?.length) {
|
if (res.code === 0 && res.data.track?.points?.length) {
|
||||||
const points = res.data.track.points.map(item => ({
|
const points = res.data.track.points.map(item => ({
|
||||||
lon: item.longitude || item.lon,
|
lng: item.longitude || item.lon,
|
||||||
lat: item.latitude || item.lat
|
lat: item.latitude || item.lat
|
||||||
}));
|
}));
|
||||||
setPoints(points);
|
setPoints(points);
|
||||||
|
|||||||
@@ -61,6 +61,14 @@ export default class DeviceController {
|
|||||||
|
|
||||||
// ========== 【集成】页面切前台重连 ==========
|
// ========== 【集成】页面切前台重连 ==========
|
||||||
handleVisibilityChange() {
|
handleVisibilityChange() {
|
||||||
|
// 切后台:关闭 WS
|
||||||
|
if (document.visibilityState === 'hidden') {
|
||||||
|
console.log('🔌 页面切后台,关闭 WebSocket');
|
||||||
|
wsManager.close();
|
||||||
|
|
||||||
|
this.isControlled = false;
|
||||||
|
this.onControlStatusChange?.(false);
|
||||||
|
}
|
||||||
if (document.visibilityState === 'visible' && this.currentDevice) {
|
if (document.visibilityState === 'visible' && this.currentDevice) {
|
||||||
if (!this.currentDevice?.serialNumber) return;
|
if (!this.currentDevice?.serialNumber) return;
|
||||||
console.log('✅ 页面切回前台,自动重连 WebSocket');
|
console.log('✅ 页面切回前台,自动重连 WebSocket');
|
||||||
|
|||||||
Reference in New Issue
Block a user