import { Card } from "@heroui/react"; import { Thunderbolt, PlugConnection, CreditCard, ChartColumn } from "@gravity-ui/icons"; import { api } from "@/lib/api"; export const dynamic = "force-dynamic"; type CardColor = "accent" | "success" | "warning" | "default"; const colorStyles: Record = { accent: { border: "border-accent", bg: "bg-accent/10", icon: "text-accent" }, success: { border: "border-success", bg: "bg-success/10", icon: "text-success" }, warning: { border: "border-warning", bg: "bg-warning/10", icon: "text-warning" }, default: { border: "border-border", bg: "bg-default", icon: "text-muted" }, }; function StatusDot({ color }: { color: "success" | "warning" | "muted" }) { const cls = color === "success" ? "bg-success" : color === "warning" ? "bg-warning" : "bg-muted/40"; return ; } function StatCard({ title, value, footer, icon: Icon, color = "default", }: { title: string; value: string | number; footer?: React.ReactNode; icon?: React.ComponentType<{ className?: string }>; color?: CardColor; }) { const s = colorStyles[color]; return (

{title}

{Icon && (
)}

{value}

{footer && (
{footer}
)}
); } export default async function DashboardPage() { const stats = await api.stats.get().catch(() => null); const todayKwh = stats ? (stats.todayEnergyWh / 1000).toFixed(1) : "—"; const offlineCount = (stats?.totalChargePoints ?? 0) - (stats?.onlineChargePoints ?? 0); return (

概览

实时运营状态

{stats?.onlineChargePoints ?? 0} 在线 · {offlineCount} 离线 } /> 最近 2 分钟有心跳} /> {stats?.activeTransactions ? "活跃中" : "当前空闲"} } /> 已注册卡片总量} /> 当日 00:00 起累计} />
); }