"use client"; import { ServerApi } from "@/app/types/nezha-api"; import { nezhaFetcher } from "@/lib/utils"; import useSWR from "swr"; import { geoJsonString } from "../../../lib/geo-json-string"; import GlobalInfo from "./GlobalInfo"; import GlobalLoading from "./GlobalLoading"; import { InteractiveMap } from "./InteractiveMap"; import { TooltipProvider } from "./TooltipContext"; export default function ServerGlobal() { const { data: nezhaServerList, error } = useSWR( "/api/server", nezhaFetcher, ); if (error) return (

{error.message}

); if (!nezhaServerList) { return ; } const countryList: string[] = []; const serverCounts: { [key: string]: number } = {}; nezhaServerList.result.forEach((server) => { if (server.host.CountryCode) { const countryCode = server.host.CountryCode.toUpperCase(); if (!countryList.includes(countryCode)) { countryList.push(countryCode); } serverCounts[countryCode] = (serverCounts[countryCode] || 0) + 1; } }); const width = 900; const height = 500; const geoJson = JSON.parse(geoJsonString); const filteredFeatures = geoJson.features.filter( (feature: any) => feature.properties.iso_a3_eh !== "", ); return (
); }