卡片的自适应修改

This commit is contained in:
mmc
2026-05-14 09:37:15 +08:00
parent c0e8a1cd3e
commit 2ae097eed0
10 changed files with 874 additions and 790 deletions

View File

@@ -66,13 +66,44 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
const totalMowers = devicesAll?.filter(d => d.productName?.includes('割草机')).length || 0;
const activeMowers = devicesAll?.filter(d => d.productName?.includes('割草机') && d.onlineStatus === 1).length || 0;
const washDroneStandby = planedevices?.filter(d => d.productName?.includes('清洗') && d.onlineStatus === 1).length || 0;
return [
{ title: '无人机机场状态', icon: <EnvironmentOutlined />, value: `${onlineDrones} / ${totalDrones}`, desc: onlineDrones > 0 ? '在线' : '离线', sub: `可调度 ${onlineDrones} 架`, color: '#1890ff' },
//{ title: '巡检机器人', icon: <RobotOutlined />, value: `${totalRobots} 台`, desc: '', sub: `执行中 ${activeRobots}`, color: '#722ed1' },
{ title: '机器人', icon: <BranchesOutlined />, value: `${totalMowers} 台`, desc: '', sub: `作业中 ${activeMowers}`, color: '#13c2c2' },
{ title: '无人机', icon: <CloudOutlined />, value: `${totalDrones} 架`, desc: '', sub: `待命 ${planedevices?.filter(d => d.productName?.includes('清洗') && d.onlineStatus === 1).length || 0}`, color: '#eb2f96' },
{ title: '设备平均电量', icon: <ThunderboltOutlined />, value: '86%', desc: '', sub: '', color: '#52c41a' },
{ title: '今日任务执行', icon: <CheckCircleOutlined />, value: '12 / 15', desc: '', sub: '完成率 80%', color: '#2f54eb' },
{
title: '无人机机场状态',
icon: <EnvironmentOutlined />,
value: `${onlineDrones} / ${totalDrones}`,
sub: `可调度 ${onlineDrones} 架`,
color: '#1890ff'
},
{
title: '机器人',
icon: <BranchesOutlined />,
value: `${totalMowers} 台`,
sub: `作业中 ${activeMowers}`,
color: '#13c2c2'
},
{
title: '无人机',
icon: <CloudOutlined />,
value: `${totalDrones} 架`,
sub: `待命 ${washDroneStandby}`,
color: '#eb2f96'
},
{
title: '设备平均电量',
icon: <ThunderboltOutlined />,
value: '86%',
sub: '',
color: '#52c41a'
},
{
title: '今日任务执行',
icon: <CheckCircleOutlined />,
value: '12 / 15',
sub: '完成率 80%',
color: '#2f54eb'
},
];
}, [devicesAll, planedevices]);
@@ -139,24 +170,55 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
return (
<Content style={{ maxWidth: 1800, margin: '0 auto', }}>
{/*<AgoraTextTest />*/}
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '16px', marginBottom: 20 }}>
<Row gutter={[16, 16]} style={{ marginBottom: 20, flexWrap: 'wrap' }}>
{dynamicTopCards.map((card, idx) => (
<div key={idx} style={{ flex: 1 }}>
<Card bordered={false} style={{ borderRadius: 12, boxShadow: '0 2px 8px rgba(0,0,0,0.05)', height: '110px', display: 'flex', alignItems: 'center' }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 12, width: '100%' }}>
<div style={{ width: 48, height: 48, borderRadius: 10, background: `${card.color}15`, color: card.color, display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 20 }}>
<Col key={idx} style={{ minWidth: '200px', flex: '0 0 auto' }}>
<Card
bordered={false}
style={{
borderRadius: 12,
boxShadow: '0 2px 8px rgba(0,0,0,0.05)',
width: 200,
height: 110,
}}
bodyStyle={{ padding: '16px', height: '100%' }}
>
<div style={{ display: 'flex', alignItems: 'center', gap: 12, height: '100%' }}>
{/* 左侧图标 */}
<div
style={{
width: 48,
height: 48,
borderRadius: 10,
background: `${card.color}15`,
color: card.color,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
fontSize: 20,
flexShrink: 0,
}}
>
{card.icon}
</div>
<div style={{ flex: 1 }}>
{/* 右侧文字 */}
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{ fontSize: 13, color: '#666' }}>{card.title}</div>
<div style={{ fontSize: 24, fontWeight: 700, color: '#222' }}>{card.value}</div>
{card.sub && <div style={{ fontSize: 12, color: '#999' }}>{card.sub}</div>}
<div style={{ fontSize: 24, fontWeight: 700, color: '#222', lineHeight: '30px' }}>
{card.value}
</div>
{card.sub && (
<div style={{ fontSize: 12, color: '#999', marginTop: 2 }}>
{card.sub}
</div>
)}
</div>
</div>
</Card>
</div>
</Col>
))}
</div>
</Row>
<Row gutter={16}>
<Col xs={24} lg={14}>