diff --git a/src/components/FleetTcpPingPanel.tsx b/src/components/FleetTcpPingPanel.tsx index c2e96b1..d63fd4f 100644 --- a/src/components/FleetTcpPingPanel.tsx +++ b/src/components/FleetTcpPingPanel.tsx @@ -1,16 +1,25 @@ import { Activity } from 'lucide-react' -import { Progress } from './ui/progress' import { cn } from '../utils/cn' -const carrierStyles: Record = { - 移动: { color: 'text-lime-300', bar: 'bg-lime-400' }, - 电信: { color: 'text-amber-300', bar: 'bg-amber-400' }, - 联通: { color: 'text-orange-300', bar: 'bg-orange-400' }, +const carrierStyles: Record = { + 电信: { color: 'text-sky-200', fill: 'bg-orange-400' }, + 联通: { color: 'text-violet-200', fill: 'bg-rose-400' }, + 移动: { color: 'text-lime-200', fill: 'bg-amber-400' }, } -function score(avg: number | null) { +function score(avg: number | null, loss: number | null) { if (avg == null) return 0 - return Math.max(4, Math.min(100, 100 - avg / 5)) + const latencyScore = 100 - avg / 5 + const lossPenalty = (loss ?? 0) * 2 + return Math.max(2, Math.min(100, latencyScore - lossPenalty)) +} + +function segmentClass(index: number, activeSegments: number, loss: number | null, fill: string) { + if (index >= activeSegments) return 'bg-slate-950/90' + const lossRate = loss ?? 0 + if (lossRate >= 8 && index % 3 === 1) return 'bg-rose-400' + if (lossRate >= 3 && index % 5 === 2) return 'bg-yellow-300' + return fill } interface Props { @@ -22,25 +31,39 @@ interface Props { export function FleetTcpPingPanel({ rows, loading, readable = true }: Props) { const hasRows = rows.some(r => r.count > 0) return ( -
-
- TCP 三网 Ping - {readable ? (hasRows ? 'LIVE' : loading ? 'SYNC' : 'NO DATA') : 'NO ACCESS'} +
+
+ + + 三网 TCPing + + {readable ? (hasRows ? 'LIVE' : loading ? 'SYNC' : 'NO DATA') : 'NO ACCESS'}
-
+
{rows.map(item => { const style = carrierStyles[item.name] - const pct = score(item.avg) + const pct = score(item.avg, item.loss) + const activeSegments = Math.round((pct / 100) * 24) return ( -
- - +
+ {item.name} - - - {item.avg == null ? '—' : `${Math.round(item.avg)}ms`} - +
+ {Array.from({ length: 24 }).map((_, idx) => ( + + ))} +
+
+
{item.avg == null ? '—' : `${Math.round(item.avg)}ms`}
+
{item.loss == null ? '—' : `${item.loss.toFixed(0)}%`}
+
) })}