From f9f57e4d1912c096cdd7803e38ee6ff3a42f586d Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Tue, 21 Jan 2025 10:39:52 +0800 Subject: [PATCH] perf: fully optimize --- .../detail/ServerDetailClient.tsx | 6 +++--- app/(main)/ClientComponents/main/Global.tsx | 4 ++-- .../ClientComponents/main/InteractiveMap.tsx | 5 +++-- app/(main)/ClientComponents/main/MapTooltip.tsx | 6 +++--- .../ClientComponents/main/ServerListClient.tsx | 6 ++++-- .../main/ServerOverviewClient.tsx | 10 +++++----- app/api/detail/route.ts | 2 +- app/api/monitor/route.ts | 2 +- biome.json | 5 ++++- components/ui/animated-circular-progress-bar.tsx | 1 + lib/logo-class.tsx | 15 ++++++++------- styles/globals.css | 4 ++-- 12 files changed, 37 insertions(+), 29 deletions(-) diff --git a/app/(main)/ClientComponents/detail/ServerDetailClient.tsx b/app/(main)/ClientComponents/detail/ServerDetailClient.tsx index 3a53eea..f75d5d4 100644 --- a/app/(main)/ClientComponents/detail/ServerDetailClient.tsx +++ b/app/(main)/ClientComponents/detail/ServerDetailClient.tsx @@ -40,7 +40,7 @@ export default function ServerDetailClient({ if (hasHistory) { router.back() } else { - router.push(`/`) + router.push("/") } } @@ -120,8 +120,8 @@ export default function ServerDetailClient({
{" "} {uptime / 86400 >= 1 - ? (uptime / 86400).toFixed(0) + " " + t("Days") - : (uptime / 3600).toFixed(0) + " " + t("Hours")}{" "} + ? `${(uptime / 86400).toFixed(0)} ${t("Days")}` + : `${(uptime / 3600).toFixed(0)} ${t("Hours")}`}
diff --git a/app/(main)/ClientComponents/main/Global.tsx b/app/(main)/ClientComponents/main/Global.tsx index 3c5d9ed..546f927 100644 --- a/app/(main)/ClientComponents/main/Global.tsx +++ b/app/(main)/ClientComponents/main/Global.tsx @@ -24,7 +24,7 @@ export default function ServerGlobal() { const countryList: string[] = [] const serverCounts: { [key: string]: number } = {} - nezhaServerList.result.forEach((server) => { + for (const server of nezhaServerList.result) { if (server.host.CountryCode) { const countryCode = server.host.CountryCode.toUpperCase() if (!countryList.includes(countryCode)) { @@ -32,7 +32,7 @@ export default function ServerGlobal() { } serverCounts[countryCode] = (serverCounts[countryCode] || 0) + 1 } - }) + } const width = 900 const height = 500 diff --git a/app/(main)/ClientComponents/main/InteractiveMap.tsx b/app/(main)/ClientComponents/main/InteractiveMap.tsx index 989931f..34682b3 100644 --- a/app/(main)/ClientComponents/main/InteractiveMap.tsx +++ b/app/(main)/ClientComponents/main/InteractiveMap.tsx @@ -40,6 +40,7 @@ export function InteractiveMap({ xmlns="http://www.w3.org/2000/svg" className="w-full h-auto" > + Interactive Map @@ -55,14 +56,14 @@ export function InteractiveMap({ fill="transparent" onMouseEnter={() => setTooltipData(null)} /> - {filteredFeatures.map((feature, index) => { + {filteredFeatures.map((feature) => { const isHighlighted = countries.includes(feature.properties.iso_a2_eh) const serverCount = serverCounts[feature.properties.iso_a2_eh] || 0 return ( - {sortedServers.map((server, index) => ( -
+ {sortedServers.map((server) => ( +
+ /> {server.name}
))} diff --git a/app/(main)/ClientComponents/main/ServerListClient.tsx b/app/(main)/ClientComponents/main/ServerListClient.tsx index e763989..1bf90a5 100644 --- a/app/(main)/ClientComponents/main/ServerListClient.tsx +++ b/app/(main)/ClientComponents/main/ServerListClient.tsx @@ -124,16 +124,17 @@ export default function ServerListClient() { } const tagCountMap: Record = {} - filteredServersByStatus.forEach((server) => { + for (const server of filteredServersByStatus) { if (server.tag) { tagCountMap[server.tag] = (tagCountMap[server.tag] || 0) + 1 } - }) + } return ( <>