"use client"; import { GeoData } from '../../api/types'; interface GeoAnalyticsProps { data: GeoData[]; } export default function GeoAnalytics({ data }: GeoAnalyticsProps) { // 安全地格式化数字 const formatNumber = (value: any): string => { if (value === undefined || value === null) return '0'; return typeof value === 'number' ? value.toLocaleString() : String(value); }; // 安全地格式化百分比 const formatPercent = (value: any): string => { if (value === undefined || value === null) return '0'; return typeof value === 'number' ? value.toFixed(2) : String(value); }; return (
{data.map((item, index) => ( ))}
Location Visits Unique Visitors Percentage
{item.city ? `${item.city}, ${item.region}, ${item.country}` : item.region ? `${item.region}, ${item.country}` : item.country || item.location || 'Unknown'} {formatNumber(item.visits)} {formatNumber(item.uniqueVisitors || item.visitors)}
{formatPercent(item.percentage)}%
); }