diff --git a/app/(main)/ClientComponents/detail/NetworkChart.tsx b/app/(main)/ClientComponents/detail/NetworkChart.tsx index 2210d5b..007f293 100644 --- a/app/(main)/ClientComponents/detail/NetworkChart.tsx +++ b/app/(main)/ClientComponents/detail/NetworkChart.tsx @@ -27,7 +27,13 @@ interface ResultItem { [key: string]: number } -export function NetworkChartClient({ server_id, show }: { server_id: number; show: boolean }) { +export function NetworkChartClient({ + server_id, + show, +}: { + server_id: number + show: boolean +}) { const t = useTranslations("NetworkChartClient") const { data, error } = useSWR( `/api/monitor?server_id=${server_id}`, diff --git a/app/(main)/ClientComponents/detail/ServerDetailChartClient.tsx b/app/(main)/ClientComponents/detail/ServerDetailChartClient.tsx index 81df8a4..a003b1e 100644 --- a/app/(main)/ClientComponents/detail/ServerDetailChartClient.tsx +++ b/app/(main)/ClientComponents/detail/ServerDetailChartClient.tsx @@ -84,7 +84,13 @@ export default function ServerDetailChartClient({ ) } -function CpuChart({ history, data }: { history: ServerDataWithTimestamp[]; data: NezhaAPISafe }) { +function CpuChart({ + history, + data, +}: { + history: ServerDataWithTimestamp[] + data: NezhaAPISafe +}) { const [cpuChartData, setCpuChartData] = useState([] as cpuChartData[]) const hasInitialized = useRef(false) const [historyLoaded, setHistoryLoaded] = useState(false) @@ -309,7 +315,13 @@ function ProcessChart({ ) } -function MemChart({ data, history }: { data: NezhaAPISafe; history: ServerDataWithTimestamp[] }) { +function MemChart({ + data, + history, +}: { + data: NezhaAPISafe + history: ServerDataWithTimestamp[] +}) { const t = useTranslations("ServerDetailChartClient") const [memChartData, setMemChartData] = useState([] as memChartData[]) const hasInitialized = useRef(false) @@ -463,7 +475,13 @@ function MemChart({ data, history }: { data: NezhaAPISafe; history: ServerDataWi ) } -function DiskChart({ data, history }: { data: NezhaAPISafe; history: ServerDataWithTimestamp[] }) { +function DiskChart({ + data, + history, +}: { + data: NezhaAPISafe + history: ServerDataWithTimestamp[] +}) { const t = useTranslations("ServerDetailChartClient") const [diskChartData, setDiskChartData] = useState([] as diskChartData[]) const hasInitialized = useRef(false) diff --git a/app/(main)/ClientComponents/detail/ServerDetailClient.tsx b/app/(main)/ClientComponents/detail/ServerDetailClient.tsx index 31deca1..63de747 100644 --- a/app/(main)/ClientComponents/detail/ServerDetailClient.tsx +++ b/app/(main)/ClientComponents/detail/ServerDetailClient.tsx @@ -7,11 +7,16 @@ import { ServerDetailLoading } from "@/components/loading/ServerDetailLoading" import { Badge } from "@/components/ui/badge" import { Card, CardContent } from "@/components/ui/card" import { cn, formatBytes } from "@/lib/utils" +import countries from "i18n-iso-countries" import { useTranslations } from "next-intl" import { notFound, useRouter } from "next/navigation" import { useEffect, useState } from "react" -export default function ServerDetailClient({ server_id }: { server_id: number }) { +export default function ServerDetailClient({ + server_id, +}: { + server_id: number +}) { const t = useTranslations("ServerDetailClient") const router = useRouter() @@ -56,6 +61,8 @@ export default function ServerDetailClient({ server_id }: { server_id: number }) if (!data) return + countries.registerLocale(require("i18n-iso-countries/langs/en.json")) + return (
- - -
-

{t("Region")}

-
-
{data?.host.CountryCode.toUpperCase()}
- + {data?.host.CountryCode && ( + + +
+

{t("Region")}

+
+
+ {countries.getName(data?.host.CountryCode, "en")} +
+ +
-
- - + + + )}
{data?.host.Platform && ( diff --git a/app/layout.tsx b/app/layout.tsx index deddd14..4084638 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -45,7 +45,11 @@ export const viewport: Viewport = { userScalable: false, } -export default async function LocaleLayout({ children }: { children: React.ReactNode }) { +export default async function LocaleLayout({ + children, +}: { + children: React.ReactNode +}) { const locale = await getLocale() const messages = await getMessages() diff --git a/bun.lockb b/bun.lockb index 939a7d0..6853d55 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/ServerCard.tsx b/components/ServerCard.tsx index 8f2b376..a3cf301 100644 --- a/components/ServerCard.tsx +++ b/components/ServerCard.tsx @@ -9,7 +9,11 @@ import { cn, formatBytes, formatNezhaInfo } from "@/lib/utils" import { useTranslations } from "next-intl" import Link from "next/link" -export default function ServerCard({ serverInfo }: { serverInfo: NezhaAPISafe }) { +export default function ServerCard({ + serverInfo, +}: { + serverInfo: NezhaAPISafe +}) { const t = useTranslations("ServerCard") const { id, name, country_code, online, cpu, up, down, mem, stg, host } = formatNezhaInfo(serverInfo) diff --git a/components/ServerCardInline.tsx b/components/ServerCardInline.tsx index dabc426..624a94c 100644 --- a/components/ServerCardInline.tsx +++ b/components/ServerCardInline.tsx @@ -10,7 +10,11 @@ import Link from "next/link" import { Separator } from "./ui/separator" -export default function ServerCardInline({ serverInfo }: { serverInfo: NezhaAPISafe }) { +export default function ServerCardInline({ + serverInfo, +}: { + serverInfo: NezhaAPISafe +}) { const t = useTranslations("ServerCard") const { id, name, country_code, online, cpu, up, down, mem, stg, host } = formatNezhaInfo(serverInfo) diff --git a/components/Switch.tsx b/components/Switch.tsx index 624672e..84a90a1 100644 --- a/components/Switch.tsx +++ b/components/Switch.tsx @@ -19,7 +19,10 @@ export default function Switch({ const scrollRef = useRef(null) const tagRefs = useRef(allTag.map(() => createRef())) const t = useTranslations("ServerListClient") - const [indicator, setIndicator] = useState<{ x: number; w: number }>({ x: 0, w: 0 }) + const [indicator, setIndicator] = useState<{ x: number; w: number }>({ + x: 0, + w: 0, + }) useEffect(() => { const savedTag = sessionStorage.getItem("selectedTag") diff --git a/components/TabSwitch.tsx b/components/TabSwitch.tsx index bc71aeb..df6f3fc 100644 --- a/components/TabSwitch.tsx +++ b/components/TabSwitch.tsx @@ -14,7 +14,10 @@ export default function TabSwitch({ setCurrentTab: (tab: string) => void }) { const t = useTranslations("TabSwitch") - const [indicator, setIndicator] = useState<{ x: number; w: number }>({ x: 0, w: 0 }) + const [indicator, setIndicator] = useState<{ x: number; w: number }>({ + x: 0, + w: 0, + }) const tabRefs = useRef<(HTMLDivElement | null)[]>([]) useEffect(() => { diff --git a/components/ThemeSwitcher.tsx b/components/ThemeSwitcher.tsx index e0de48a..f9cec88 100644 --- a/components/ThemeSwitcher.tsx +++ b/components/ThemeSwitcher.tsx @@ -37,19 +37,25 @@ export function ModeToggle() { handleSelect(e, "light")} > {t("Light")} {theme === "light" && } handleSelect(e, "dark")} > {t("Dark")} {theme === "dark" && } handleSelect(e, "system")} > {t("System")} {theme === "system" && } diff --git a/lib/serverFetch.tsx b/lib/serverFetch.tsx index 63d6956..78076c1 100644 --- a/lib/serverFetch.tsx +++ b/lib/serverFetch.tsx @@ -126,7 +126,11 @@ export async function GetServerMonitor({ server_id }: { server_id: number }) { } } -export async function GetServerIP({ server_id }: { server_id: number }): Promise { +export async function GetServerIP({ + server_id, +}: { + server_id: number +}): Promise { let nezhaBaseUrl = getEnv("NezhaBaseUrl") if (!nezhaBaseUrl) { console.error("NezhaBaseUrl is not set") diff --git a/package.json b/package.json index 5d1ad47..32b163a 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "d3-selection": "^3.0.0", "eslint-plugin-simple-import-sort": "^12.1.1", "flag-icons": "^7.2.3", + "i18n-iso-countries": "^7.13.0", "lucide-react": "^0.454.0", "luxon": "^3.5.0", "maxmind": "^4.3.23", @@ -73,7 +74,7 @@ "postcss": "^8.4.49", "tailwindcss": "^4.0.0-beta.8", "typescript": "^5.7.2", - "vercel": "^39.2.4" + "vercel": "^39.2.5" }, "overrides": { "react-is": "^19.0.0-rc-69d4b800-20241021"