"use client"; import { useEffect, useState } from "react"; import Link from "next/link"; import { Warning, ChartLine, Robot } from "@phosphor-icons/react"; import { AdminLayout } from "@/components/layout/admin-layout"; import { PageHeader } from "@/components/layout/page-header"; import { Card } from "@/components/ui/card"; import { useAuth } from "@/hooks/use-auth"; import { adminGetMetrics } from "@/lib/frontend/api-client"; interface EntryCard { href: string; title: string; desc: string; icon: typeof Warning; badge?: number; } export default function DashboardPage() { const { token } = useAuth(); const [openAlerts, setOpenAlerts] = useState(0); useEffect(() => { if (!token) return; void adminGetMetrics("", token).then((res) => { if (res.code === 0) { setOpenAlerts(res.data.open_alerts_count); } }); }, [token]); const entries: EntryCard[] = [ { href: "/admin/alerts", title: "预警中心", desc: "处理 RPA 失败、价格偏差与降级预警", icon: Warning, badge: openAlerts, }, { href: "/admin/rpa", title: "RPA 状态", desc: "查看 Worker 在线状态、队列深度与熔断", icon: Robot, }, { href: "/admin/dashboard", title: "指标看板", desc: "API/RPA 成功率、缓存命中率与 P95 延迟", icon: ChartLine, }, ]; return (
{entries.map((entry) => { const Icon = entry.icon; return (
{entry.badge ? ( {entry.badge} 条待处理 ) : null}

{entry.title}

{entry.desc}

); })}
); }