获取机器人 逻辑改为单独页面获取 优化无人机视频切换和无人机数据获取逻辑
This commit is contained in:
@@ -18,7 +18,7 @@ import {
|
||||
Calendar, User, TrendingUp, Maximize2, Play, Square, X, MapPin, RotateCw
|
||||
} from 'lucide-react';
|
||||
import {
|
||||
getsinglePlan, getsinglePlanTrack, updateFlightTaskStatus, postFlightCommmand, getWayLine, createWaylineTask, getFlightTaskDetail
|
||||
getsinglePlan, getsinglePlanTrack, updateFlightTaskStatus, postFlightCommmand, getWayLine, createWaylineTask, getFlightTaskDetail, getSiteUAVList
|
||||
} from '@/api/device';
|
||||
import dayjs from 'dayjs';
|
||||
import utils from '@/lib/utils';
|
||||
@@ -27,11 +27,16 @@ import { getUAVState } from '@/api/device';
|
||||
import { fix2, getVal } from '@/lib/utils';
|
||||
import { useMqtt } from '@/hooks/useMqtt';
|
||||
import envConfig from '../../../env';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { RootState } from '@/store';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
const { RangePicker } = DatePicker;
|
||||
|
||||
export default function WayLinePage({ planedevices, onRefresh }) {
|
||||
export default function WayLinePage({ onRefresh }) {
|
||||
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||
const { stationId } = useSelector((state: RootState) => state.station);
|
||||
|
||||
const fontSmall = 'clamp(10px, 0.7vw, 11px)';
|
||||
const fontNormal = 'clamp(12px, 0.75vw, 13px)';
|
||||
const fontTitle = 'clamp(14px, 0.85vw, 16px)';
|
||||
@@ -40,6 +45,7 @@ export default function WayLinePage({ planedevices, onRefresh }) {
|
||||
const cardStyle = { borderRadius: 12, border: 'none', boxShadow: '0 2px 12px rgba(0,0,0,0.04)' };
|
||||
|
||||
// 任务列表 独立筛选状态
|
||||
const [planedevices, setPlaneDevices] = useState([]);
|
||||
const [listDrone, setListDrone] = useState(null);
|
||||
const [listDroneRealtime, setListDroneRealtime] = useState(null);
|
||||
const [listDateRange, setListDateRange] = useState(null);
|
||||
@@ -47,6 +53,39 @@ export default function WayLinePage({ planedevices, onRefresh }) {
|
||||
const [persistentDroneData, setPersistentDroneData] = useState(null); // 持久化无人机数据
|
||||
const [persistentHostData, setPersistentHostData] = useState(null); // 持久化机场数据
|
||||
|
||||
// 获取数据
|
||||
const fetchAllData = async () => {
|
||||
if (!stationId) return;
|
||||
|
||||
try {
|
||||
const planeRes = await getSiteUAVList(stationId);
|
||||
|
||||
// 处理无人机 + 自动补全地图需要的字段
|
||||
let planeData = planeRes?.code === 200 ? (planeRes?.rows || []) : [];
|
||||
|
||||
planeData = planeData.map(item => ({
|
||||
...item,
|
||||
type: 'plane',
|
||||
lastRunningStatus: {
|
||||
longitude: item.longitude || 0,
|
||||
latitude: item.latitude || 0,
|
||||
},
|
||||
deviceAlias: item.drone_callsign || item.device_sn
|
||||
|| '无人机',
|
||||
|
||||
}));
|
||||
|
||||
setPlaneDevices(planeData);
|
||||
|
||||
} catch (err) {
|
||||
console.error('数据请求失败', err);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchAllData();
|
||||
}, [userInfo, stationId]);
|
||||
|
||||
const listDroneTimerRef = useRef<any>(null);
|
||||
|
||||
// 当MQTT数据更新时,更新持久化数据(只在有新数据时更新)
|
||||
|
||||
Reference in New Issue
Block a user