"use client" import {useMemo, useState} from "react" import Section from "@/components/shared/section" import MetricCard from "@/components/shared/metric-card" import {Activity, Cpu, Filter, Satellite, Wifi} from 'lucide-react' import {Button} from "@/components/ui/button" import {type ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent,} from "@/components/ui/chart" import {Bar, BarChart, CartesianGrid, Line, LineChart, ResponsiveContainer, XAxis, YAxis,} from "recharts" import {Card, CardContent, CardHeader, CardTitle} from "@/components/ui/card" import MapDistribution from "@/components/map/map-distribution" import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue} from "@/components/ui/select" function useMonitoringData() { const devices = 18860 const types = [ { name: "流量计", value: 5200 }, { name: "压力传感", value: 4300 }, { name: "液位传感", value: 3720 }, { name: "阀门状态", value: 2640 }, ] const onlineRate = 96.8 const trend = Array.from({ length: 14 }).map((_, i) => ({ t: `${i + 1}时`, online: 95 + Math.sin(i / 2) * 2 + (i % 3) * 0.2, alarms: Math.max(0, Math.round(60 + 8 * Math.sin(i / 1.5) + (i % 4) * 2)), })) return { devices, types, onlineRate, trend } } const onlineConfig = { online: { label: "在线率", color: "hsl(var(--chart-1))" }, } satisfies ChartConfig const alarmConfig = { alarms: { label: "报警数", color: "hsl(var(--chart-5))" }, } satisfies ChartConfig export default function MonitoringDashboard() { const { devices, types, onlineRate, trend } = useMonitoringData() const [industry, setIndustry] = useState("all") const [risk, setRisk] = useState("all") const [refreshing, setRefreshing] = useState(false) const typesBar = useMemo( () => types.map((t) => ({ name: t.name, value: t.value })), [types], ) return (
{ setRefreshing(true) setTimeout(() => setRefreshing(false), 800) }} > {refreshing ? "刷新中..." : "刷新数据"} } >
} /> } /> } trend={{ delta: 0.4, label: "近24h" }} /> acc + cur.alarms, 0)} icon={} />
在线率(近14小时) } /> 设备类型分布 } />
} > ) }