'use client'; import { Globe2 } from 'lucide-react'; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from '@/components/ui/card'; import { Progress } from '@/components/ui/progress'; import type { DistributionItem } from '@/lib/services/openflare'; import { formatCompactNumber } from './dashboard-utils'; export function GeoDistributionList({ items }: { items: DistributionItem[] }) { const sortedItems = [...items] .sort((left, right) => right.value - left.value) .slice(0, 8); const maxValue = sortedItems[0]?.value ?? 0; return ( 来源国家分布 聚合最近 24 小时主要来源国家。 {sortedItems.length === 0 ? (
暂无来源分布数据
) : (
{sortedItems.map((item) => { const ratio = maxValue > 0 ? (item.value / maxValue) * 100 : 0; return (
{item.key || '未知'} {formatCompactNumber(item.value)}
); })}
)}
); }