"use client" import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog" import { Card, CardContent } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" import { Activity, Clock, Zap, AlertTriangle, CheckCircle } from "lucide-react" import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, AreaChart, Area } from "recharts" interface APIMonitorDialogProps { open: boolean onOpenChange: (open: boolean) => void api?: { name: string endpoint: string } } const LATENCY_DATA = [ { time: "00:00", p50: 28, p95: 45, p99: 68 }, { time: "04:00", p50: 25, p95: 42, p99: 62 }, { time: "08:00", p50: 32, p95: 55, p99: 85 }, { time: "12:00", p50: 45, p95: 78, p99: 120 }, { time: "16:00", p50: 42, p95: 72, p99: 110 }, { time: "20:00", p50: 35, p95: 58, p99: 88 }, ] const QPS_DATA = [ { time: "00:00", qps: 450 }, { time: "04:00", qps: 280 }, { time: "08:00", qps: 850 }, { time: "12:00", qps: 1200 }, { time: "16:00", qps: 1100 }, { time: "20:00", qps: 780 }, ] const ERROR_DATA = [ { time: "00:00", rate: 0.1 }, { time: "04:00", rate: 0.05 }, { time: "08:00", rate: 0.15 }, { time: "12:00", rate: 0.3 }, { time: "16:00", rate: 0.2 }, { time: "20:00", rate: 0.12 }, ] export function APIMonitorDialog({ open, onOpenChange, api }: APIMonitorDialogProps) { return ( API监控 - {api?.name || "API服务"} {api?.endpoint} {/* 实时指标 */}

当前QPS

1,156

峰值: 1,200

P99延迟

95ms

P50: 32ms

成功率

99.85%

SLA: 99.9%

今日错误

156

较昨日 -23%

{/* QPS趋势 */}

QPS趋势

{/* 延迟分布 */}

延迟分布 (ms)

{/* 最近错误 */}

最近错误

{[ { time: "14:35:12", code: 429, message: "Rate limit exceeded", count: 23 }, { time: "14:32:08", code: 500, message: "Internal server error", count: 5 }, { time: "14:28:45", code: 404, message: "User not found", count: 12 }, ].map((error, i) => (
{error.code} {error.message}
{error.count} 次 {error.time}
))}
) }