import { Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis, } from "recharts"; import { Card, CardBody, CardHeader } from "@/shadcn-bridge/heroui/card"; import { PageEmptyState } from "@/components/page-state"; interface FlowChartPoint { time: string; flow: number; } interface FlowChartCardProps { statisticsFlowsCount: number; chartData: FlowChartPoint[]; formatFlow: (value: number, unit?: string) => string; } export const FlowChartCard = ({ statisticsFlowsCount, chartData, formatFlow, }: FlowChartCardProps) => { return (

24小时流量统计

{statisticsFlowsCount === 0 ? ( ) : (
{ const v = typeof value === "number" ? value : Number(value); if (!Number.isFinite(v)) return String(value); if (v === 0) return "0"; if (v < 1024) return `${v}B`; if (v < 1024 * 1024) return `${(v / 1024).toFixed(1)}K`; if (v < 1024 * 1024 * 1024) return `${(v / (1024 * 1024)).toFixed(1)}M`; return `${(v / (1024 * 1024 * 1024)).toFixed(1)}G`; }} tickLine={false} /> ; label?: string | number; }) => { if (active && payload && payload.length) { const firstValue = payload[0]?.value; const numericValue = typeof firstValue === "number" ? firstValue : Number(firstValue); const flowValue = Number.isFinite(numericValue) ? numericValue : 0; return (

{`时间: ${label ?? ""}`}

{`流量: ${formatFlow(flowValue)}`}

); } return null; }} cursor={{ fill: "rgba(0, 122, 255, 0.05)" }} />
)}
); };