diff --git a/app/(main)/ClientComponents/Global.tsx b/app/(main)/ClientComponents/Global.tsx index 4e70787..4ff5f10 100644 --- a/app/(main)/ClientComponents/Global.tsx +++ b/app/(main)/ClientComponents/Global.tsx @@ -1,13 +1,12 @@ import { countryCodeMapping, reverseCountryCodeMapping } from "@/lib/geo"; import { countryCoordinates } from "@/lib/geo-limit"; import { GetNezhaData } from "@/lib/serverFetch"; -import { ServerStackIcon } from "@heroicons/react/20/solid"; import * as turf from "@turf/turf"; import DottedMap from "dotted-map/without-countries"; -import Link from "next/link"; import { geoJsonString } from "../../../lib/geo-json-string"; import { mapJsonString } from "../../../lib/map-string"; +import GlobalInfo from "./GlobalInfo"; interface GlobalProps { countries?: string[]; @@ -30,6 +29,7 @@ export default async function ServerGlobal() { } export async function Global({ countries = [] }: GlobalProps) { + // const t = useTranslations("Global"); const map = new DottedMap({ map: JSON.parse(mapJsonString) }); const countries_alpha3 = countries @@ -96,12 +96,7 @@ export async function Global({ countries = [] }: GlobalProps) { return (
- - - + World Map with Highlighted Countries + +

+ {t("Distributions")} {countries.length} {t("Regions")} +

+
+ ); +} diff --git a/app/(main)/ClientComponents/GlobalLoading.tsx b/app/(main)/ClientComponents/GlobalLoading.tsx new file mode 100644 index 0000000..a87fb4a --- /dev/null +++ b/app/(main)/ClientComponents/GlobalLoading.tsx @@ -0,0 +1,18 @@ +"use client"; + +import GlobalBackButton from "@/components/GlobalBackButton"; +import { Loader } from "@/components/loading/Loader"; +import { useTranslations } from "next-intl"; + +export default function GlobalLoading() { + const t = useTranslations("Global"); + return ( +
+ +
+ {t("Loading")} + +
+
+ ); +} diff --git a/app/(main)/ClientComponents/ServerListClient.tsx b/app/(main)/ClientComponents/ServerListClient.tsx index d6f3cd4..a6add8a 100644 --- a/app/(main)/ClientComponents/ServerListClient.tsx +++ b/app/(main)/ClientComponents/ServerListClient.tsx @@ -23,13 +23,11 @@ export default function ServerListClient() { const [tag, setTag] = useState(defaultTag); - const [isMounted, setIsMounted] = useState(false); useEffect(() => { const savedTag = sessionStorage.getItem("selectedTag") || defaultTag; setTag(savedTag); restoreScrollPosition(); - setIsMounted(true); }, []); const handleTagChange = (newTag: string) => { @@ -71,7 +69,7 @@ export default function ServerListClient() { ); - if (!data?.result || !isMounted) return null; + if (!data?.result) return null; const { result } = data; const sortedServers = result.sort((a, b) => { @@ -123,6 +121,7 @@ export default function ServerListClient() { onClick={() => { setStatus("all"); setFilter(false); + sessionStorage.removeItem("selectedTag"); router.push(`/?global=true`); }} className="rounded-[50px] bg-stone-100 p-[10px] transition-all hover:bg-stone-200 dark:hover:bg-stone-700 dark:bg-stone-800" diff --git a/app/(main)/page.tsx b/app/(main)/page.tsx index 32f2ce9..680118f 100644 --- a/app/(main)/page.tsx +++ b/app/(main)/page.tsx @@ -1,11 +1,9 @@ import ServerList from "@/components/ServerList"; import ServerOverview from "@/components/ServerOverview"; -import { Loader } from "@/components/loading/Loader"; -import { ServerStackIcon } from "@heroicons/react/20/solid"; -import Link from "next/link"; import { Suspense } from "react"; import ServerGlobal from "./ClientComponents/Global"; +import GlobalLoading from "./ClientComponents/GlobalLoading"; export default async function Home({ searchParams, @@ -18,22 +16,7 @@ export default async function Home({ {!global && } {global && ( - - - - -
- Loading... - -
- - } - > + }> )} diff --git a/components/GlobalBackButton.tsx b/components/GlobalBackButton.tsx new file mode 100644 index 0000000..29de85c --- /dev/null +++ b/components/GlobalBackButton.tsx @@ -0,0 +1,24 @@ +"use client"; + +import { ServerStackIcon } from "@heroicons/react/20/solid"; +import { useRouter } from "next/navigation"; +import { useEffect } from "react"; + +export default function GlobalBackButton() { + const router = useRouter(); + + useEffect(() => { + router.prefetch(`/`); + }, []); + + return ( + + ); +} diff --git a/messages/en.json b/messages/en.json index 0cd4436..1d11b51 100644 --- a/messages/en.json +++ b/messages/en.json @@ -90,6 +90,11 @@ "p_2277-2331_Overview": "👋 Overview", "p_2390-2457_wherethetimeis": "where the time is" }, + "Global": { + "Loading": "Loading...", + "Distributions": "Servers are distributed in", + "Regions": "Regions" + }, "NotFoundPage": { "h1_490-590_404NotFound": "404 Not Found", "p_601-665_TARDISERROR": "TARDIS ERROR!", diff --git a/messages/ja.json b/messages/ja.json index 133b746..82a6e03 100644 --- a/messages/ja.json +++ b/messages/ja.json @@ -90,6 +90,11 @@ "p_2277-2331_Overview": "👋 概要", "p_2390-2457_wherethetimeis": "現在の時間" }, + "Global": { + "Loading": "Loading...", + "Distributions": "サーバーは", + "Regions": "つの地域に分散されています" + }, "NotFoundPage": { "h1_490-590_404NotFound": "404 見つかりませんでした", "p_601-665_TARDISERROR": "ターディスエラー!", diff --git a/messages/zh-t.json b/messages/zh-t.json index 0d9d18b..9066286 100644 --- a/messages/zh-t.json +++ b/messages/zh-t.json @@ -90,6 +90,11 @@ "p_2277-2331_Overview": "👋 概覽", "p_2390-2457_wherethetimeis": "當前時間" }, + "Global": { + "Loading": "載入中...", + "Distributions": "伺服器分佈在", + "Regions": "個地區" + }, "NotFoundPage": { "h1_490-590_404NotFound": "404 未找到", "p_601-665_TARDISERROR": "TARDIS 錯誤!", diff --git a/messages/zh.json b/messages/zh.json index 0a3ec83..6a40e29 100644 --- a/messages/zh.json +++ b/messages/zh.json @@ -90,6 +90,11 @@ "p_2277-2331_Overview": "👋 概览", "p_2390-2457_wherethetimeis": "当前时间" }, + "Global": { + "Loading": "加载中...", + "Distributions": "服务器分布在", + "Regions": "个地区" + }, "NotFoundPage": { "h1_490-590_404NotFound": "404 未找到", "p_601-665_TARDISERROR": "TARDIS 错误!",