地图上显示无人机

This commit is contained in:
mmc
2026-05-22 14:36:31 +08:00
parent 53cd28807b
commit e1d11a69d8
3 changed files with 39 additions and 20 deletions

View File

@@ -15,7 +15,6 @@ const DeviceStatusSettingPage = ({ serialNumber }) => (
<div style={{ padding: 20 }}>
<h2>设置状态页面</h2>
<p>当前查看设备序列号: <span style={{ fontWeight: 'bold', color: '#1890ff' }}>{serialNumber || '未选择设备'}</span></p>
{/* 这里后续可以根据 serialNumber 加载具体的设备状态详情 */}
</div>
);
@@ -33,7 +32,7 @@ export default function DeviceIndexPage() {
{ key: 'wayLineTask', label: '航线任务', icon: <AimOutlined /> },
];
// 👇 核心修复:同时请求 + 同时合并
// 👇 核心:给无人机补全 lastRunningStatus + type: 'plane'
const fetchAllData = async () => {
if (!userInfo?.username) return;
@@ -44,17 +43,37 @@ export default function DeviceIndexPage() {
getPlaneDeviceList(),
]);
// 2. 处理设备数据
// 2. 处理普通设备
const devData = deviceRes?.code === 200 ? (deviceRes.data || []) : [];
const planeData = planeRes?.code === 200 ? (planeRes.data?.detail || []) : [];
// 3. 处理无人机 + 自动补全地图需要的字段(关键改动)
let planeData = planeRes?.code === 200 ? (planeRes.data?.detail || []) : [];
// ====================== ✅ 核心改造 ======================
planeData = planeData.map(item => ({
...item,
// 给无人机统一设置 type: plane
type: 'plane',
// 自动生成 lastRunningStatus(经纬度取无人机自身字段)
lastRunningStatus: {
longitude: item.longitude || 0,
latitude: item.latitude || 0,
},
// 兼容地图取设备名/序列号
deviceAlias: item.drone_callsign || item.device_sn
|| '无人机',
}));
// ========================================================
setDevices(devData);
setPlaneDevices(planeData);
// 合并所有设备
const all = [...devData, ...planeData];
setDevicesAll(all);
// 如果当前没选中,默认选第一个
// 默认选中第一个
if (!selectedSn && all.length > 0) {
setSelectedSn(all[0].device_sn || all[0].serialNumber);
}
@@ -100,7 +119,6 @@ export default function DeviceIndexPage() {
<div style={{ display: 'flex', paddingBottom: "4px" }}>
<div style={{ padding: '8px 12px 0', flexShrink: 0 }}>
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>装备控制</Typography.Title>
{/*<Text type="secondary" style={{ fontSize: '12px' }}>装备总览、状态监控与参数配置</Text>*/}
</div>
<Header style={{
@@ -117,8 +135,8 @@ export default function DeviceIndexPage() {
border: '0',
height: 40,
lineHeight: '40px',
background: 'transparent', // 这里直接写,不需要 !important
backgroundColor: 'transparent' // 兼容更好
background: 'transparent',
backgroundColor: 'transparent'
}} />
</Header>
</div>