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
269e2fcd13
commit
2c6dcdf53f
@ -7,14 +7,14 @@ import { InteractiveMap } from "./InteractiveMap";
|
|||||||
export default async function ServerGlobal() {
|
export default async function ServerGlobal() {
|
||||||
const nezhaServerList = await GetNezhaData();
|
const nezhaServerList = await GetNezhaData();
|
||||||
|
|
||||||
const countrytList: string[] = [];
|
const countryList: string[] = [];
|
||||||
const serverCounts: { [key: string]: number } = {};
|
const serverCounts: { [key: string]: number } = {};
|
||||||
|
|
||||||
nezhaServerList.result.forEach((server) => {
|
nezhaServerList.result.forEach((server) => {
|
||||||
if (server.host.CountryCode) {
|
if (server.host.CountryCode) {
|
||||||
const countryCode = server.host.CountryCode.toUpperCase();
|
const countryCode = server.host.CountryCode.toUpperCase();
|
||||||
if (!countrytList.includes(countryCode)) {
|
if (!countryList.includes(countryCode)) {
|
||||||
countrytList.push(countryCode);
|
countryList.push(countryCode);
|
||||||
}
|
}
|
||||||
serverCounts[countryCode] = (serverCounts[countryCode] || 0) + 1;
|
serverCounts[countryCode] = (serverCounts[countryCode] || 0) + 1;
|
||||||
}
|
}
|
||||||
@ -25,15 +25,15 @@ export default async function ServerGlobal() {
|
|||||||
|
|
||||||
const geoJson = JSON.parse(geoJsonString);
|
const geoJson = JSON.parse(geoJsonString);
|
||||||
const filteredFeatures = geoJson.features.filter(
|
const filteredFeatures = geoJson.features.filter(
|
||||||
(feature: any) => feature.properties.iso_a3 !== "",
|
(feature: any) => feature.properties.iso_a3_eh !== "",
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="flex flex-col gap-4 mt-[3.2px]">
|
<section className="flex flex-col gap-4 mt-[3.2px]">
|
||||||
<GlobalInfo countries={countrytList} />
|
<GlobalInfo countries={countryList} />
|
||||||
<div className="w-full overflow-x-auto">
|
<div className="w-full overflow-x-auto">
|
||||||
<InteractiveMap
|
<InteractiveMap
|
||||||
countries={countrytList}
|
countries={countryList}
|
||||||
serverCounts={serverCounts}
|
serverCounts={serverCounts}
|
||||||
width={width}
|
width={width}
|
||||||
height={height}
|
height={height}
|
||||||
|
@ -57,11 +57,13 @@ export function InteractiveMap({
|
|||||||
<g>
|
<g>
|
||||||
{filteredFeatures.map((feature, index) => {
|
{filteredFeatures.map((feature, index) => {
|
||||||
const isHighlighted = countries_alpha3.includes(
|
const isHighlighted = countries_alpha3.includes(
|
||||||
feature.properties.iso_a3,
|
feature.properties.iso_a3_eh,
|
||||||
);
|
);
|
||||||
|
|
||||||
const countryCode = Object.entries(countryCodeMapping).find(
|
const countryCode = Object.entries(countryCodeMapping).find(
|
||||||
([, alpha3]) => alpha3 === feature.properties.iso_a3,
|
([, alpha3]) => alpha3 === feature.properties.iso_a3_eh,
|
||||||
)?.[0];
|
)?.[0];
|
||||||
|
|
||||||
const serverCount = countryCode
|
const serverCount = countryCode
|
||||||
? serverCounts[countryCode] || 0
|
? serverCounts[countryCode] || 0
|
||||||
: 0;
|
: 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user