diff --git a/frontend/web/src/components/StatCard.tsx b/frontend/web/src/components/StatCard.tsx index 9aa4be4..9de7f29 100644 --- a/frontend/web/src/components/StatCard.tsx +++ b/frontend/web/src/components/StatCard.tsx @@ -1,5 +1,5 @@ -import { Card, Statistic } from 'antd' -import type { ReactNode } from 'react' +import { Card } from 'antd' +import type { CSSProperties, ReactNode } from 'react' type Color = 'blue' | 'green' | 'orange' | 'purple' | 'red' @@ -18,23 +18,42 @@ interface StatCardProps { value: number | string suffix?: string precision?: number - valueStyle?: React.CSSProperties + valueStyle?: CSSProperties + subText?: string } -export default function StatCard({ icon, color = 'blue', title, value, suffix, precision, valueStyle }: StatCardProps) { +export default function StatCard({ icon, color = 'blue', title, value, suffix, precision, valueStyle, subText }: StatCardProps) { const c = colorMap[color] + const display = typeof value === 'number' && precision != null ? value.toFixed(precision) : value return ( - -
+ +
- {icon} + {icon} +
+
+
+ {title} +
+
+ {display} + {suffix && {suffix}} +
+
+ {subText ?? ''} +
-
) diff --git a/frontend/web/src/pages/Home.tsx b/frontend/web/src/pages/Home.tsx index 048a842..326b767 100644 --- a/frontend/web/src/pages/Home.tsx +++ b/frontend/web/src/pages/Home.tsx @@ -92,7 +92,7 @@ export default function HomePage() { } color="orange" title="累计执行" value={stats?.runs_count ?? 0} - suffix={stats?.today_runs ? ` / 今日 ${stats.today_runs}` : undefined} + subText={stats?.today_runs ? `今日 ${stats.today_runs} 次` : undefined} />