mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
fix(global): use iso_a3_eh
This commit is contained in:
parent
86c6de0cb5
commit
2cd1a91ab8
@ -7,14 +7,14 @@ import { InteractiveMap } from "./InteractiveMap";
|
||||
export default async function ServerGlobal() {
|
||||
const nezhaServerList = await GetNezhaData();
|
||||
|
||||
const countrytList: string[] = [];
|
||||
const countryList: string[] = [];
|
||||
const serverCounts: { [key: string]: number } = {};
|
||||
|
||||
nezhaServerList.result.forEach((server) => {
|
||||
if (server.host.CountryCode) {
|
||||
const countryCode = server.host.CountryCode.toUpperCase();
|
||||
if (!countrytList.includes(countryCode)) {
|
||||
countrytList.push(countryCode);
|
||||
if (!countryList.includes(countryCode)) {
|
||||
countryList.push(countryCode);
|
||||
}
|
||||
serverCounts[countryCode] = (serverCounts[countryCode] || 0) + 1;
|
||||
}
|
||||
@ -25,15 +25,15 @@ export default async function ServerGlobal() {
|
||||
|
||||
const geoJson = JSON.parse(geoJsonString);
|
||||
const filteredFeatures = geoJson.features.filter(
|
||||
(feature: any) => feature.properties.iso_a3 !== "",
|
||||
(feature: any) => feature.properties.iso_a3_eh !== "",
|
||||
);
|
||||
|
||||
return (
|
||||
<section className="flex flex-col gap-4 mt-[3.2px]">
|
||||
<GlobalInfo countries={countrytList} />
|
||||
<GlobalInfo countries={countryList} />
|
||||
<div className="w-full overflow-x-auto">
|
||||
<InteractiveMap
|
||||
countries={countrytList}
|
||||
countries={countryList}
|
||||
serverCounts={serverCounts}
|
||||
width={width}
|
||||
height={height}
|
||||
|
@ -57,11 +57,13 @@ export function InteractiveMap({
|
||||
<g>
|
||||
{filteredFeatures.map((feature, index) => {
|
||||
const isHighlighted = countries_alpha3.includes(
|
||||
feature.properties.iso_a3,
|
||||
feature.properties.iso_a3_eh,
|
||||
);
|
||||
|
||||
const countryCode = Object.entries(countryCodeMapping).find(
|
||||
([, alpha3]) => alpha3 === feature.properties.iso_a3,
|
||||
([, alpha3]) => alpha3 === feature.properties.iso_a3_eh,
|
||||
)?.[0];
|
||||
|
||||
const serverCount = countryCode
|
||||
? serverCounts[countryCode] || 0
|
||||
: 0;
|
||||
|
Loading…
Reference in New Issue
Block a user