import {
TrendingUp,
TrendingDown,
Server,
Wifi,
CheckCircle,
PackageCheck,
Wrench,
Target,
Clock,
Upload
} from "lucide-react";
import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, Cell } from "recharts";
interface MetricCardProps {
label: string;
value: string;
trend?: "up" | "down";
trendValue?: string;
color?: string;
icon: React.ElementType;
}
function MetricCard({ label, value, trend, trendValue, color = "#1890FF", icon: Icon }: MetricCardProps) {
return (
{label}
{value}
{trend && trendValue && (
{trend === "up" ? : }
{trendValue}
)}
);
}
interface TaskItemProps {
deviceSN: string;
description: string;
time?: string;
}
function TaskItem({ deviceSN, description, time }: TaskItemProps) {
return (
);
}
export default function Dashboard() {
const metrics = [
{ label: "设备总数", value: "5,234", trend: "up" as const, trendValue: "+5.2%", color: "#1890FF", icon: Server },
{ label: "在线设备", value: "4,856", trend: "up" as const, trendValue: "+2.8%", color: "#52C41A", icon: Wifi },
{ label: "已激活", value: "4,912", trend: "up" as const, trendValue: "+1.5%", color: "#1890FF", icon: CheckCircle },
{ label: "有新版本", value: "156", color: "#722ED1", icon: PackageCheck },
{ label: "维修中", value: "23", trend: "down" as const, trendValue: "-12.3%", color: "#FF4D4F", icon: Wrench },
{ label: "待校准", value: "56", color: "#FA8C16", icon: Target },
{ label: "授权即将到期", value: "45", color: "#FAAD14", icon: Clock },
{ label: "升级中", value: "8", color: "#13C2C2", icon: Upload },
];
const deviceStatusData = [
{ name: "在线", value: 4856, color: "#52C41A" },
{ name: "离线", value: 378, color: "#FF4D4F" },
{ name: "维修", value: 23, color: "#FAAD14" },
{ name: "报废", value: 77, color: "#8C8C8C" },
];
const taskGroups = [
{
title: "待校准设备",
count: 12,
tasks: [
{ deviceSN: "SN2024030801", description: "温度传感器校准到期", time: "2小时前" },
{ deviceSN: "SN2024030802", description: "压力传感器校准到期", time: "3小时前" },
{ deviceSN: "SN2024030803", description: "湿度传感器校准到期", time: "5小时前" },
],
},
{
title: "固件升级通知",
count: 8,
tasks: [
{ deviceSN: "SN2024030710", description: "固件版本v2.3.5可用", time: "1天前" },
{ deviceSN: "SN2024030711", description: "固件版本v2.3.5可用", time: "1天前" },
],
},
{
title: "待授权审批",
count: 15,
tasks: [
{ deviceSN: "SN2024030620", description: "设备授权申请待审批", time: "30分钟前" },
{ deviceSN: "SN2024030621", description: "设备授权申请待审批", time: "1小时前" },
{ deviceSN: "SN2024030622", description: "设备授权延期申请", time: "2小时前" },
],
},
{
title: "维修工单",
count: 5,
tasks: [
{ deviceSN: "SN2024030530", description: "设备故障报修", time: "4小时前" },
{ deviceSN: "SN2024030531", description: "定期维护到期", time: "6小时前" },
],
},
];
return (
{/* Page Header */}
{/* Metric Cards */}
{metrics.map((metric, index) => (
))}
{/* Device Status Chart */}
设备状态分布
{deviceStatusData.map((entry) => (
|
))}
{/* Pending Tasks */}
待处理任务
{taskGroups.map((group, groupIndex) => (
{group.title}
{group.count}
{group.tasks.map((task, taskIndex) => (
))}
{group.tasks.length < group.count && (
)}
))}
);
}