import { AlertOutlined, AppstoreOutlined, AuditOutlined, BarChartOutlined, BellOutlined, CheckCircleOutlined, CloudServerOutlined, DatabaseOutlined, DownloadOutlined, FileDoneOutlined, FileTextOutlined, HomeOutlined, InboxOutlined, LineChartOutlined, LogoutOutlined, MenuFoldOutlined, PlusOutlined, ProductOutlined, ProjectOutlined, QuestionCircleOutlined, SearchOutlined, SettingOutlined, ShopOutlined, ShoppingCartOutlined, SolutionOutlined, TeamOutlined, ThunderboltOutlined, ToolOutlined, UploadOutlined, UserOutlined, WalletOutlined, } from "@ant-design/icons"; import ReactECharts from "echarts-for-react"; import { Avatar, Badge, Button, DatePicker, Descriptions, Dropdown, Drawer, Form, Input, Progress, Select, Space, Tag, } from "antd"; import type { MenuProps } from "antd"; import type { ReactNode } from "react"; import { useEffect } from "react"; import type { ActivityItem, DrawerMode, IconName, MetricItem, NavItem, NoticeItem, QuickAction, RankingItem, TaskProgressItem, TemplateTone, TodoItem, WorkOrderPriority, WorkOrderRecord, WorkOrderStatus, } from "./types"; const iconMap: Record = { home: , analytics: , business: , customer: , order: , product: , finance: , supply: , hr: , system: , app: , ticket: , task: , monitor: , alert: , device: , report: , setting: , import: , export: , help: , user: , cart: , approval: , contract: , dashboard: , }; const toneHex: Record = { blue: "#3b82f6", cyan: "#06b6d4", green: "#16a34a", mint: "#10b981", purple: "#7c3aed", orange: "#f97316", red: "#ef4444", slate: "#64748b", }; const toneGradient: Record = { blue: "linear-gradient(135deg, #60a5fa 0%, #2563eb 100%)", cyan: "linear-gradient(135deg, #22d3ee 0%, #0891b2 100%)", green: "linear-gradient(135deg, #34d399 0%, #059669 100%)", mint: "linear-gradient(135deg, #5eead4 0%, #10b981 100%)", purple: "linear-gradient(135deg, #a78bfa 0%, #7c3aed 100%)", orange: "linear-gradient(135deg, #fdba74 0%, #f97316 100%)", red: "linear-gradient(135deg, #fb7185 0%, #ef4444 100%)", slate: "linear-gradient(135deg, #cbd5e1 0%, #64748b 100%)", }; const workOrderStatusMeta: Record< WorkOrderStatus, { label: string; color: string } > = { pending: { label: "待处理", color: "gold" }, processing: { label: "处理中", color: "blue" }, done: { label: "已完成", color: "green" }, cancelled: { label: "已取消", color: "default" }, }; const priorityMeta: Record = { high: { label: "高", color: "red" }, medium: { label: "中", color: "gold" }, low: { label: "低", color: "green" }, }; function toneClass(tone: TemplateTone) { return `bp-admin-tone-${tone}`; } export function IconGlyph(props: { name: IconName; tone?: TemplateTone; className?: string; }) { return ( {iconMap[props.name]} ); } export function AdminShell(props: { variant: "glass" | "mint" | "ops" | "work"; activeKey: string; navItems: NavItem[]; brandTitle: string; brandSubtitle: string; topbar: ReactNode; children: ReactNode; sidebarFooter?: ReactNode; onNavChange?: (key: string) => void; }) { return (
{props.topbar}
{props.children}
); } export function AdminTopbar(props: { title: string; subtitle?: string; searchPlaceholder?: string; extra?: ReactNode; userName?: string; }) { const displayName = props.userName || "管理员"; const userMenuItems: MenuProps["items"] = [ { key: "profile", icon: , label: "个人信息", }, { key: "logout", icon: , label: "退出登录", danger: true, }, ]; return (
{props.title} {props.subtitle ? {props.subtitle} : null}
} placeholder={props.searchPlaceholder || "搜索功能、数据、报表"} allowClear /> {props.extra}
); } export function Panel(props: { title?: string; extra?: ReactNode; className?: string; children: ReactNode; }) { return (
{props.title || props.extra ? (
{props.title ?

{props.title}

: } {props.extra}
) : null} {props.children}
); } export function Sparkline(props: { values: number[]; tone: TemplateTone; filled?: boolean; }) { const min = Math.min(...props.values); const max = Math.max(...props.values); const span = Math.max(max - min, 1); const points = props.values .map((value, index) => { const x = (index / Math.max(props.values.length - 1, 1)) * 120; const y = 42 - ((value - min) / span) * 34; return `${x},${y}`; }) .join(" "); const fillPoints = `0,48 ${points} 120,48`; return ( ); } export function MetricCard({ metric }: { metric: MetricItem }) { const positive = metric.direction !== "down"; return (
{metric.label}
{metric.value}
较昨日 {positive ? "↑" : "↓"} {metric.delta}
); } export function QuickActionGrid(props: { actions: QuickAction[]; onAction?: (action: QuickAction) => void; compact?: boolean; }) { return (
{props.actions.map((action) => ( ))}
); } export function RankingList({ items }: { items: RankingItem[] }) { return (
    {items.map((item) => (
  1. {item.rank} {item.name} {item.amount}
  2. ))}
); } export function ActivityList({ items }: { items: ActivityItem[] }) { return (
{items.map((item) => (
{item.content}
))}
); } export function NoticeList({ items }: { items: NoticeItem[] }) { return (
{items.map((item) => (
{item.title} {item.description}
))}
); } export function TodoList({ items }: { items: TodoItem[] }) { return (
{items.map((item) => ( ))}
); } export function TaskProgressList({ items }: { items: TaskProgressItem[] }) { return (
{items.map((item) => (
{item.title} {item.percent}% {item.status}
))}
); } export function HealthScore(props: { value: number; title?: string; tone?: TemplateTone; }) { const tone = props.tone || "mint"; return (
( {props.value} {props.title || "健康"} )} />
{["服务器状态", "接口服务", "数据库状态", "存储空间"].map((item) => ( {item} 正常 ))}
); } export function DashboardChart(props: { option: Record; height?: number; }) { return ( ); } export function TemplateActionDrawer(props: { open: boolean; title: string; mode: DrawerMode; onClose: () => void; onSubmit: () => void; }) { if (!props.open) { return null; } return ; } function TemplateActionDrawerInner(props: { open: boolean; title: string; mode: DrawerMode; onClose: () => void; onSubmit: () => void; }) { const [form] = Form.useForm(); useEffect(() => { if (props.open) { form.setFieldsValue({ subject: props.title, owner: "张伟", priority: "medium", department: "运营部", }); } else { form.resetFields(); } }, [form, props.open, props.title]); return ( } >
)}
); }