- ConfigProvider 注入全局配置(动画、表格尺寸) - CSS Variables 主题微调(页面背景、圆角、字体栈) - AppLayout Menu 支持 logo/operations/collapsed - Statistic 组件增加 color/prefix/suffix/animation - Card 组件启用 hoverShadow/headerBordered - Table 组件启用 stripe 斑马纹 - Tag 组件使用 variant="light" + shape="round" - Dialog 居中显示并设置固定宽度 - 布局样式硬编码颜色替换为 TDesign Token - UsageChart 改用 AreaChart + 渐变填充 - 更新 frontend spec 同步样式体系要求
76 lines
2.2 KiB
TypeScript
76 lines
2.2 KiB
TypeScript
import { Row, Col, Card, Statistic } from 'tdesign-react';
|
|
import { ChartBarIcon, ChartLineIcon, ServerIcon, Calendar1Icon } from 'tdesign-icons-react';
|
|
import type { UsageStats } from '@/types';
|
|
|
|
interface StatCardsProps {
|
|
stats: UsageStats[];
|
|
}
|
|
|
|
export function StatCards({ stats }: StatCardsProps) {
|
|
const totalRequests = stats.reduce((sum, s) => sum + s.requestCount, 0);
|
|
const activeModels = new Set(stats.map((s) => s.modelName)).size;
|
|
const activeProviders = new Set(stats.map((s) => s.providerId)).size;
|
|
|
|
const today = new Date().toISOString().split('T')[0];
|
|
const todayRequests = stats
|
|
.filter((s) => s.date === today)
|
|
.reduce((sum, s) => sum + s.requestCount, 0);
|
|
|
|
return (
|
|
<Row gutter={[16, 16]} style={{ marginBottom: 16 }}>
|
|
<Col xs={12} md={6}>
|
|
<Card bordered={false} hoverShadow>
|
|
<Statistic
|
|
title="总请求量"
|
|
value={totalRequests}
|
|
color="blue"
|
|
prefix={<ChartBarIcon />}
|
|
suffix="次"
|
|
animation={{ duration: 800, valueFrom: 0 }}
|
|
animationStart
|
|
/>
|
|
</Card>
|
|
</Col>
|
|
<Col xs={12} md={6}>
|
|
<Card bordered={false} hoverShadow>
|
|
<Statistic
|
|
title="活跃模型数"
|
|
value={activeModels}
|
|
color="green"
|
|
prefix={<ChartLineIcon />}
|
|
suffix="个"
|
|
animation={{ duration: 800, valueFrom: 0 }}
|
|
animationStart
|
|
/>
|
|
</Card>
|
|
</Col>
|
|
<Col xs={12} md={6}>
|
|
<Card bordered={false} hoverShadow>
|
|
<Statistic
|
|
title="活跃供应商数"
|
|
value={activeProviders}
|
|
color="orange"
|
|
prefix={<ServerIcon />}
|
|
suffix="个"
|
|
animation={{ duration: 800, valueFrom: 0 }}
|
|
animationStart
|
|
/>
|
|
</Card>
|
|
</Col>
|
|
<Col xs={12} md={6}>
|
|
<Card bordered={false} hoverShadow>
|
|
<Statistic
|
|
title="今日请求量"
|
|
value={todayRequests}
|
|
color="red"
|
|
prefix={<Calendar1Icon />}
|
|
suffix="次"
|
|
animation={{ duration: 800, valueFrom: 0 }}
|
|
animationStart
|
|
/>
|
|
</Card>
|
|
</Col>
|
|
</Row>
|
|
);
|
|
}
|