设备状态界面
This commit is contained in:
@@ -44,11 +44,16 @@ const logs = [
|
||||
];
|
||||
|
||||
// 设备总览组件
|
||||
export default function DeviceOverviewPage({ devices, planedevices, devicesAll, onViewStatus }) {
|
||||
const [selectedDevice, setSelectedDevice] = useState(null);
|
||||
export default function DeviceOverviewPage({ devices, planedevices, devicesAll, onViewStatus, selectedSn, onDeviceSelect }) {
|
||||
const [planeVideo, setPlaneVideo] = useState([]); // 初始为空数组
|
||||
const [zoomedVideo, setZoomedVideo] = useState(null); // 放大查看的视频数据
|
||||
|
||||
// 衍生状态:从 SN 获取设备对象
|
||||
const selectedDevice = React.useMemo(() => {
|
||||
const sn = selectedSn || (devicesAll?.[0]?.device_sn || devicesAll?.[0]?.serialNumber);
|
||||
return devicesAll?.find(item => (item.device_sn || item.serialNumber) === sn) || null;
|
||||
}, [devicesAll, selectedSn]);
|
||||
|
||||
// 动态计算顶部卡片数据
|
||||
const dynamicTopCards = React.useMemo(() => {
|
||||
const totalDrones = planedevices?.length || 0;
|
||||
@@ -119,19 +124,15 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
const getVal = (val) => val == "no_rain" ? "无" : (val || '-');
|
||||
|
||||
// 默认选中第一个
|
||||
useEffect(() => {
|
||||
if (devicesAll && devicesAll.length > 0) {
|
||||
setSelectedDevice(devicesAll[0]); // 🔥 修复:存整个对象
|
||||
}
|
||||
}, [devicesAll]);
|
||||
useEffect(() => {
|
||||
getLiveDefault();
|
||||
}, [selectedDevice])
|
||||
|
||||
// 切换设备
|
||||
const handleDeviceChange = (id) => {
|
||||
const target = devicesAll.find(item => (item.device_sn || item.serialNumber) === id);
|
||||
setSelectedDevice(target || null); // 🔥 修复:存对象
|
||||
if (onDeviceSelect) {
|
||||
onDeviceSelect(id);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -232,7 +233,7 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
<Row gutter={16}>
|
||||
<Col span={12}>
|
||||
<div style={{ marginBottom: 24 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 16 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 16, flexWrap: "wrap" }}>
|
||||
<span style={{ fontSize: 24, color: '#1890ff' }}><RocketOutlined /></span>
|
||||
<span style={{ fontSize: 16, fontWeight: 600 }}>{selectedDevice.deviceAlias || selectedDevice.drone_callsign || selectedDevice.callsign || selectedDevice.deviceName}</span>
|
||||
<Tag color={selectedDevice.onlineStatus === 1 ? "success" : "default"} size="small">
|
||||
|
||||
Reference in New Issue
Block a user