卡片的自适应修改

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

@@ -113,120 +113,127 @@ export default function CleanOptimizationPage() {
return (
<div style={{ background: '#f0f2f5', minHeight: '100vh', padding: '16px 24px' }}>
{/* 顶部指标卡片 */}
<Row gutter={12} style={{ marginBottom: 16 }}>
<Col span={4}>
<Card bordered={false} bodyStyle={{ padding: '16px' }} style={{ borderRadius: 8 }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div>
<Text type="secondary" style={{ fontSize: 13 }}>污染指数</Text>
<div style={{ display: 'flex', alignItems: 'center', gap: 8, margin: '4px 0' }}>
<Text style={{ fontSize: 24, fontWeight: 'bold' }}>68.5</Text>
<Tag color="#52c41a" style={{ borderRadius: 10, margin: 0 }}>中等</Tag>
</div>
<div style={{ fontSize: 12 }}>
<Text type="secondary">较昨日</Text>
<Text style={{ color: '#ff4d4f', marginLeft: 4, fontWeight: 'bold' }}>▼ 5.3</Text>
</div>
</div>
<div style={{ width: 40, height: 40, borderRadius: '50%', background: '#fff7e6', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<SunOutlined style={{ color: '#faad14', fontSize: 20 }} />
</div>
</div>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} bodyStyle={{ padding: '16px' }} style={{ borderRadius: 8 }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div>
<Text type="secondary" style={{ fontSize: 13 }}>建议清洗区块数</Text>
<div style={{ margin: '4px 0' }}>
<Text style={{ fontSize: 24, fontWeight: 'bold' }}>8 / 20</Text>
</div>
<div style={{ fontSize: 12 }}>
<Text type="secondary">占比 40%</Text>
</div>
</div>
<div style={{ width: 40, height: 40, borderRadius: '50%', background: '#e6f7ff', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<LayoutGrid size={20} color="#1890ff" />
</div>
</div>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} bodyStyle={{ padding: '16px' }} style={{ borderRadius: 8 }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div>
<Text type="secondary" style={{ fontSize: 13 }}>预计发电提升</Text>
<div style={{ margin: '4px 0' }}>
<Text style={{ fontSize: 24, fontWeight: 'bold', color: '#1890ff' }}>12,850</Text>
<Text style={{ fontSize: 14, marginLeft: 4 }}>kWh</Text>
</div>
<div style={{ fontSize: 12 }}>
<Text type="secondary">占当前日发电量 14.2%</Text>
</div>
</div>
<div style={{ width: 40, height: 40, borderRadius: '50%', background: '#f0f5ff', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<TrendingUp size={20} color="#1890ff" />
</div>
</div>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} bodyStyle={{ padding: '16px' }} style={{ borderRadius: 8 }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div>
<Text type="secondary" style={{ fontSize: 13 }}>预计收益提升</Text>
<div style={{ margin: '4px 0' }}>
<Text style={{ fontSize: 24, fontWeight: 'bold', color: '#faad14' }}>¥ 7,286</Text>
</div>
<div style={{ fontSize: 12 }}>
<Text type="secondary">按电价 0.568 元/kWh 计算</Text>
</div>
</div>
<div style={{ width: 40, height: 40, borderRadius: '50%', background: '#fff7e6', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<DollarSign size={20} color="#faad14" />
</div>
</div>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} bodyStyle={{ padding: '16px' }} style={{ borderRadius: 8 }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div>
<Text type="secondary" style={{ fontSize: 13 }}>上次清洗时间</Text>
<div style={{ margin: '4px 0' }}>
<Text style={{ fontSize: 24, fontWeight: 'bold' }}>2025-05-12</Text>
</div>
<div style={{ fontSize: 12 }}>
<Text type="secondary">距今 12 天</Text>
</div>
</div>
<div style={{ width: 40, height: 40, borderRadius: '50%', background: '#f0f5ff', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<Calendar size={20} color="#1890ff" />
</div>
</div>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} bodyStyle={{ padding: '16px' }} style={{ borderRadius: 8 }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div>
<Text type="secondary" style={{ fontSize: 13 }}>清洗成本预估</Text>
<div style={{ margin: '4px 0' }}>
<Text style={{ fontSize: 24, fontWeight: 'bold', color: '#faad14' }}>¥ 3,200</Text>
</div>
<div style={{ fontSize: 12 }}>
<Text type="secondary">预计单次清洗总成本</Text>
</div>
</div>
<div style={{ width: 40, height: 40, borderRadius: '50%', background: '#e6f7ff', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<Droplets size={20} color="#1890ff" />
</div>
</div>
</Card>
</Col>
</Row>
{/* 清洗建议卡片组 —— 宽高统一 + 最小168px + 自动换行 + 风格统一 */}
<Row
gutter={[12, 12]}
style={{
marginBottom: 16,
flexWrap: 'wrap',
}}
>
{[
{
title: '污染指数',
value: '68.5',
unit: '',
tag: '中等',
tagColor: '#52c41a',
trend: '较昨日 ▼ 5.3',
trendColor: '#ff4d4f',
icon: <SunOutlined />,
color: '#faad14',
bg: '#fff7e6'
},
{
title: '建议清洗区块数',
value: '8 / 20',
unit: '',
trend: '占比 40%',
icon: <LayoutGrid />,
color: '#1890ff',
bg: '#e6f7ff'
},
{
title: '预计发电提升',
value: '12,850',
unit: 'kWh',
trend: '占当前日发电量 14.2%',
icon: <TrendingUp />,
color: '#1890ff',
bg: '#f0f5ff'
},
{
title: '预计收益提升',
value: '¥ 7,286',
unit: '',
trend: '按电价 0.568 元/kWh 计算',
icon: <DollarSign />,
color: '#faad14',
bg: '#fff7e6'
},
{
title: '上次清洗时间',
value: '2025-05-12',
unit: '',
trend: '距今 12 天',
icon: <Calendar />,
color: '#1890ff',
bg: '#f0f5ff'
},
{
title: '清洗成本预估',
value: '¥ 3,200',
unit: '',
trend: '预计单次清洗总成本',
icon: <Droplets />,
color: '#1890ff',
bg: '#e6f7ff'
},
].map((item, index) => (
<Col key={index} style={{ minWidth: '168px', flex: '1 0 auto' }}>
<Card
bordered={false}
bodyStyle={{ padding: '16px' }}
style={{ borderRadius: 8, height: 120 }}
>
<div style={{ display: 'flex', justifyContent: 'space-between', height: '100%' }}>
<div style={{ display: 'flex', flexDirection: 'column', justifyContent: 'center' }}>
<div style={{ fontSize: 13, color: '#86909C', marginBottom: 4 }}>{item.title}</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 4 }}>
<div style={{ fontSize: 24, fontWeight: 700, color: item.color }}>
{item.value}
</div>
{item.unit && (
<span style={{ fontSize: 14, color: '#4E5969' }}>{item.unit}</span>
)}
{item.tag && (
<Tag
color={item.tagColor}
style={{
borderRadius: 10,
margin: 0,
padding: '0 8px',
fontSize: 12
}}
>
{item.tag}
</Tag>
)}
</div>
<div style={{ fontSize: 12, color: item.trendColor || '#86909C' }}>
{item.trend}
</div>
</div>
<div style={{
width: 40,
height: 40,
borderRadius: '50%',
background: item.bg,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0
}}>
{React.cloneElement(item.icon, { style: { fontSize: 20, color: item.color } })}
</div>
</div>
</Card>
</Col>
))}
</Row>
{/* 标题栏 */}
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>