卡片的自适应修改

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

@@ -135,30 +135,50 @@ export default function AIDiagnosisPage() {
return (
<div style={{ background: '#f5f7fa', minHeight: '100vh', padding: '16px 24px' }}>
{/* 顶部指标卡片 */}
<Row gutter={12} style={{ marginBottom: 16 }}>
{/* 优化版:宽高统一 + 最小168px + 自动换行 + 样式统一 */}
<Row
gutter={[12, 12]}
style={{
marginBottom: 16,
flexWrap: 'wrap',
}}
>
{[
{ title: 'PR值', value: '82.6%', trend: '较昨日 -1.3%', icon: <RiseOutlined />, color: '#00B42A', bg: '#E8FFEA' },
{ title: '发电偏差', value: '-4.35%', trend: '较昨日 -1.02%', icon: <FallOutlined />, color: '#F53F3F', bg: '#FFF1F0' },
{ title: 'PR值', value: '82.6%', trend: '较昨日 -1.3%', icon: <RiseOutlined />, color: '#00B42A', bg: '#E8FFEA', trendColor: '#F53F3F' },
{ title: '发电偏差', value: '-4.35%', trend: '较昨日 -1.02%', icon: <FallOutlined />, color: '#F53F3F', bg: '#FFF1F0', trendColor: '#F53F3F' },
{ title: '异常组串数量', value: '8', trend: '较昨日 +2 ↑', icon: <AppstoreOutlined />, color: '#F53F3F', bg: '#FFF1F0', trendColor: '#F53F3F' },
{ title: '热斑疑似数量', value: '36', trend: '较昨日 +5 ↑', icon: <BellOutlined />, color: '#F53F3F', bg: '#FFF1F0', trendColor: '#F53F3F' },
{ title: '健康度评分', value: '86.3分', trend: '较昨日 -1.7', icon: <CheckCircleOutlined />, color: '#00B42A', bg: '#E8FFEA' },
{ title: '预测发电量', value: '4,821kWh', trend: '较昨日 +2.6% ↑', icon: <ThunderboltOutlined />, color: '#00B42A', bg: '#E8FFEA', trendColor: '#00B42A' },
{ title: '健康度评分', value: '86.3', unit: '分', trend: '较昨日 -1.7', icon: <CheckCircleOutlined />, color: '#00B42A', bg: '#E8FFEA', trendColor: '#F53F3F' },
{ title: '预测发电量', value: '4,821', unit: 'kWh', trend: '较昨日 +2.6% ↑', icon: <ThunderboltOutlined />, color: '#00B42A', bg: '#E8FFEA', trendColor: '#00B42A' },
].map((item, index) => (
<Col span={4} key={index}>
<Card bordered={false} bodyStyle={{ padding: 16 }} style={cardStyle}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<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', alignItems: 'center', height: '100%' }}>
<div>
<div style={{ fontSize: 14, color: '#4E5969', marginBottom: 8 }}>{item.title}</div>
<div style={{ fontSize: 24, fontWeight: 700, color: item.color }}>
{item.value.includes('分') ? <>{item.value.replace('分', '')}<span style={{ fontSize: 14 }}>分</span></> :
item.value.includes('kWh') ? <>{item.value.replace('kWh', '')}<span style={{ fontSize: 14 }}>kWh</span></> : item.value}
<div style={{ fontSize: 24, fontWeight: 700, color: item.color, display: 'flex', alignItems: 'baseline', gap: 4 }}>
{item.value}
{item.unit && <span style={{ fontSize: 14, fontWeight: 400 }}>{item.unit}</span>}
</div>
<div style={{ fontSize: 12, color: item.trendColor || '#86909C', marginTop: 8 }}>
{item.trend} {item.trend.includes('-') && <FallOutlined />}
{item.trend}
</div>
</div>
<div style={{ width: 48, height: 48, background: item.bg, borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
{React.cloneElement(item.icon as React.ReactElement, { style: { fontSize: 24, color: item.color } })}
<div style={{
width: 48,
height: 48,
background: item.bg,
borderRadius: '50%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}>
{React.cloneElement(item.icon, { style: { fontSize: 24, color: item.color } })}
</div>
</div>
</Card>