import { App as AntdApp, Button, DatePicker, Select, Space, Tag } from "antd"; import { useMemo, useState } from "react"; import { QueryState } from "@/shared/components/QueryState"; import { AdminShell, AdminTopbar, DashboardChart, HealthScore, MetricCard, NoticeList, Panel, QuickActionGrid, TemplateActionDrawer, TodoList, } from "@/shared/components/admin-ui-templates/DashboardPrimitives"; import { createBarCompareOption, createDonutOption, createLineAreaOption, } from "@/shared/components/admin-ui-templates/chartOptions"; import { mintMetrics, notices, quickActions, standardNavItems, todos, } from "@/shared/components/admin-ui-templates/sampleData"; import type { DrawerMode, QuickAction, } from "@/shared/components/admin-ui-templates/types"; type ViewState = "ready" | "loading" | "empty" | "error"; type CompareMode = "day" | "week" | "month"; const labels = ["03-04", "03-05", "03-06", "03-07", "03-08", "03-09", "03-10"]; export function MintAnalyticsDashboard() { const { message } = AntdApp.useApp(); const [activeNav, setActiveNav] = useState("home"); const [compareMode, setCompareMode] = useState("day"); const [viewState, setViewState] = useState("ready"); const [drawerAction, setDrawerAction] = useState(null); const [drawerMode, setDrawerMode] = useState("create"); const revenueOption = useMemo( () => createLineAreaOption({ colors: ["#10b981", "#3b82f6"], labels, primaryName: "营业收入", secondaryName: "订单金额", primary: [520, 570, 760, 840, 1082, 650, 1160], secondary: [380, 430, 520, 580, 710, 480, 690], }), [], ); const compareOption = useMemo( () => createBarCompareOption({ labels, series: [ { name: compareMode === "day" ? "营业收入" : "本期收入", data: [1120, 1210, 980, 1130, 1280, 900, 1100], color: "#3b82f6", }, { name: "订单金额", data: [940, 810, 730, 820, 1080, 620, 760], color: "#10b981", }, { name: "支付金额", data: [650, 590, 510, 610, 760, 430, 540], color: "#f59e0b", }, ], }), [compareMode], ); const channelOption = useMemo( () => createDonutOption({ centerLabel: "总订单数", centerValue: "12,568", data: [ { name: "线上商城 38.6%", value: 38.6, color: "#10b981" }, { name: "移动端 APP 28.7%", value: 28.7, color: "#3b82f6" }, { name: "小程序 17.3%", value: 17.3, color: "#f59e0b" }, { name: "第三方平台 10.5%", value: 10.5, color: "#fbbf24" }, { name: "线下门店 4.9%", value: 4.9, color: "#cbd5e1" }, ], }), [], ); function refresh() { setViewState("loading"); window.setTimeout(() => { setViewState("ready"); message.success("分析数据已更新"); }, 500); } function openActionDrawer(action: QuickAction, mode: DrawerMode = "create") { setDrawerAction(action); setDrawerMode(mode); } return ( 数据更新时间:2026-03-10 23:40:00 size="small" value={viewState} onChange={setViewState} options={[ { value: "ready", label: "正常" }, { value: "loading", label: "加载" }, { value: "empty", label: "空态" }, { value: "error", label: "错误" }, ]} /> } /> } sidebarFooter={ <>
快捷入口 数据报表 自定义看板 数据导出 帮助中心
} onNavChange={setActiveNav} > {viewState !== "ready" ? ( setViewState("ready")} /> ) : ( <>

晚上好,超级管理员 管理员

本周核心指标 03.04 - 03.10

{mintMetrics.map((metric) => ( ))}
{(["day", "week", "month"] as CompareMode[]).map((mode) => ( ))} } >
openActionDrawer(action)} />
{[ ["商品总数", "2,350", "5.2%"], ["库存预警", "32", "11.1%"], ["在售商品", "1,986", "3.8%"], ["库存周转率", "4.62", "6.3%"], ].map(([label, value, delta], index) => (
{label} {value} 较上周 {index === 1 ? "↓" : "↑"} {delta}
))}
)} setDrawerAction(null)} onSubmit={() => { setDrawerAction(null); message.success("表单已保存"); }} />
); }