From edd24045382648935670eb72e7c8407b909aba4a Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Wed, 25 Dec 2024 15:28:25 +0800 Subject: [PATCH] style: GlobalMap background when custom background is enable --- src/components/GlobalMap.tsx | 12 ++++++-- src/main.tsx | 55 +++++++++++++++++------------------- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/src/components/GlobalMap.tsx b/src/components/GlobalMap.tsx index 8b02150..c1d12c3 100644 --- a/src/components/GlobalMap.tsx +++ b/src/components/GlobalMap.tsx @@ -1,7 +1,7 @@ import useTooltip from "@/hooks/use-tooltip" import { geoJsonString } from "@/lib/geo-json-string" import { countryCoordinates } from "@/lib/geo-limit" -import { formatNezhaInfo } from "@/lib/utils" +import { cn, formatNezhaInfo } from "@/lib/utils" import { NezhaServer } from "@/types/nezha-api" import { geoEquirectangular, geoPath } from "d3-geo" import { useTranslation } from "react-i18next" @@ -13,6 +13,10 @@ export default function GlobalMap({ serverList, now }: { serverList: NezhaServer const countryList: string[] = [] const serverCounts: { [key: string]: number } = {} + const customBackgroundImage = + // @ts-expect-error CustomBackgroundImage is a global variable + (window.CustomBackgroundImage as string) !== "" ? window.CustomBackgroundImage : undefined + serverList.forEach((server) => { if (server.country_code) { const countryCode = server.country_code.toUpperCase() @@ -30,7 +34,11 @@ export default function GlobalMap({ serverList, now }: { serverList: NezhaServer const filteredFeatures = geoJson.features.filter((feature: { properties: { iso_a3_eh: string } }) => feature.properties.iso_a3_eh !== "") return ( -
+

{t("map.Distributions")} {countryList.length} {t("map.Regions")}

diff --git a/src/main.tsx b/src/main.tsx index f584633..1be15b4 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,6 +1,5 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query" import { ReactQueryDevtools } from "@tanstack/react-query-devtools" -import React from "react" import ReactDOM from "react-dom/client" import { Toaster } from "sonner" @@ -17,32 +16,30 @@ import "./index.css" const queryClient = new QueryClient() ReactDOM.createRoot(document.getElementById("root")!).render( - - - - - - - - - - - - - - - - - - - , + + + + + + + + + + + + + + + + + , )