import { ChevronDown, Globe2, MapPin } from "lucide-react"; import { StatusBadge } from "@/components/shared/status-badge"; import { formatDate } from "@/lib/utils"; import type { SubscriptionRiskGeoSummary } from "@/services/subscription-risk-review"; function projectPoint(latitude: number, longitude: number) { return { x: ((longitude + 180) / 360) * 360, y: ((90 - latitude) / 180) * 180, }; } function radiusForAccess(count: number) { return Math.min(7, Math.max(3, 2 + Math.sqrt(count))); } function WorldRiskMap({ summary }: { summary: SubscriptionRiskGeoSummary }) { const points = summary.points.slice(0, 60); return (
{[-120, -60, 0, 60, 120].map((longitude) => { const x = ((longitude + 180) / 360) * 360; return ; })} {[-45, 0, 45].map((latitude) => { const y = ((90 - latitude) / 180) * 180; return ; })} {points.map((point) => { const { x, y } = projectPoint(point.latitude, point.longitude); return ( {point.ip + " / " + point.country + " / " + point.region + " / " + point.city} ); })}
{points.length > 0 ? "已标注 " + points.length + " 个坐标点" : "没有可用经纬度坐标"} 圆点越大表示访问越集中
); } export function SubscriptionRiskGeoDetails({ summary }: { summary: SubscriptionRiskGeoSummary }) { return (
地区与 IP 证据 {summary.uniqueCountryCount} 国 / {summary.uniqueRegionCount} 省区 / {summary.uniqueCityCount} 城市 / {summary.uniqueIpCount} IP

访问记录

{summary.totalLogs}

不同 IP

{summary.uniqueIpCount}

{summary.countries.length === 0 ? (

暂无可识别地区数据,可能是 GeoIP 未命中或访问来源未携带有效 IP。

) : ( summary.countries.map((country) => (

{country.country}

{country.accessCount} 次

{country.ipCount} IP · {country.regionCount} 省/地区 · {country.cityCount} 城市

{(country.topRegions.length > 0 || country.topCities.length > 0) && (

省区:{country.topRegions.join("、") || "未识别"};城市:{country.topCities.join("、") || "未识别"}

)}
)) )}
最近访问明细
{summary.recentAccesses.length === 0 ? (

暂无访问明细。

) : ( summary.recentAccesses.slice(0, 6).map((access) => (
{access.ip} {access.allowed ? "放行" : access.reason || "拦截"}

{access.location}

{formatDate(access.createdAt)}

{access.userAgent &&

{access.userAgent}

}
)) )}
); }