diff --git a/app/[locale]/(main)/ClientComponents/NetworkChart.tsx b/app/[locale]/(main)/ClientComponents/NetworkChart.tsx index 83fa09b..73db61d 100644 --- a/app/[locale]/(main)/ClientComponents/NetworkChart.tsx +++ b/app/[locale]/(main)/ClientComponents/NetworkChart.tsx @@ -47,12 +47,20 @@ export function NetworkChartClient({ server_id }: { server_id: number }) { }, ); - if (error) + if (error) { return ( -
-

{error.message}

-
+ <> +
+

{error.message}

+

+ {t("chart_fetch_error_message")} +

+
+ + ); + } + if (!data) return ; function transformData(data: NezhaAPIMonitor[]) { diff --git a/app/[locale]/(main)/ClientComponents/NetworkChartLoading.tsx b/app/[locale]/(main)/ClientComponents/NetworkChartLoading.tsx index 6c23ac6..3a9c908 100644 --- a/app/[locale]/(main)/ClientComponents/NetworkChartLoading.tsx +++ b/app/[locale]/(main)/ClientComponents/NetworkChartLoading.tsx @@ -1,13 +1,23 @@ import { BackIcon } from "@/components/Icon"; import { Loader } from "@/components/loading/Loader"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { useLocale } from "next-intl"; +import { useRouter } from "next/navigation"; export default function NetworkChartLoading() { + const router = useRouter(); + const locale = useLocale(); + return (
- + { + router.push(`/${locale}/`); + }} + className="flex items-center cursor-pointer gap-0.5 text-xl" + >
diff --git a/app/[locale]/(main)/ClientComponents/ServerOverviewClient.tsx b/app/[locale]/(main)/ClientComponents/ServerOverviewClient.tsx index 14ec2a3..a4ebb7e 100644 --- a/app/[locale]/(main)/ClientComponents/ServerOverviewClient.tsx +++ b/app/[locale]/(main)/ClientComponents/ServerOverviewClient.tsx @@ -1,15 +1,14 @@ "use client"; -import { useTranslations } from "next-intl"; -import Image from "next/image"; -import useSWR from "swr"; - +import { ServerApi } from "@/app/[locale]/types/nezha-api"; import { Loader } from "@/components/loading/Loader"; import { Card, CardContent } from "@/components/ui/card"; import getEnv from "@/lib/env-entry"; import { formatBytes, nezhaFetcher } from "@/lib/utils"; import blogMan from "@/public/blog-man.webp"; -import { ServerApi } from "@/app/[locale]/types/nezha-api"; +import { useTranslations } from "next-intl"; +import Image from "next/image"; +import useSWR from "swr"; export default function ServerOverviewClient() { const t = useTranslations("ServerOverviewClient"); diff --git a/components/ServerCard.tsx b/components/ServerCard.tsx index d9c7970..c03890d 100644 --- a/components/ServerCard.tsx +++ b/components/ServerCard.tsx @@ -1,3 +1,6 @@ +import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api"; +import ServerCardPopover from "@/components/ServerCardPopover"; +import ServerFlag from "@/components/ServerFlag"; import ServerUsageBar from "@/components/ServerUsageBar"; import { Card } from "@/components/ui/card"; import { @@ -10,10 +13,6 @@ import { useLocale, useTranslations } from "next-intl"; import { env } from "next-runtime-env"; import { useRouter } from "next/navigation"; -import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api"; -import ServerCardPopover from "@/components/ServerCardPopover"; -import ServerFlag from "@/components/ServerFlag"; - export default function ServerCard({ serverInfo, }: { diff --git a/components/ServerCardPopover.tsx b/components/ServerCardPopover.tsx index c0f8031..9638802 100644 --- a/components/ServerCardPopover.tsx +++ b/components/ServerCardPopover.tsx @@ -1,8 +1,7 @@ +import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api"; import { cn, formatBytes } from "@/lib/utils"; import { useTranslations } from "next-intl"; -import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api"; - export function ServerCardPopoverCard({ className, title, diff --git a/components/ServerList.tsx b/components/ServerList.tsx index 5152f49..2c6abb2 100644 --- a/components/ServerList.tsx +++ b/components/ServerList.tsx @@ -1,6 +1,5 @@ -import React from "react"; - import ServerListClient from "@/app/[locale]/(main)/ClientComponents/ServerListClient"; +import React from "react"; export default async function ServerList() { return ; diff --git a/lib/serverFetch.tsx b/lib/serverFetch.tsx index 523f8ad..22d2451 100644 --- a/lib/serverFetch.tsx +++ b/lib/serverFetch.tsx @@ -1,10 +1,9 @@ "use server"; -import { unstable_noStore as noStore } from "next/cache"; - import { NezhaAPI, ServerApi } from "@/app/[locale]/types/nezha-api"; import { MakeOptional } from "@/app/[locale]/types/utils"; import getEnv from "@/lib/env-entry"; +import { unstable_noStore as noStore } from "next/cache"; export async function GetNezhaData() { noStore(); diff --git a/lib/utils.ts b/lib/utils.ts index 8abce68..6df8955 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -1,8 +1,7 @@ +import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api"; import { type ClassValue, clsx } from "clsx"; import { twMerge } from "tailwind-merge"; -import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api"; - export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } diff --git a/messages/en.json b/messages/en.json index 880aac0..3d09ae7 100644 --- a/messages/en.json +++ b/messages/en.json @@ -29,7 +29,8 @@ "Offline": "Offline" }, "NetworkChartClient": { - "avg_delay": "Latency" + "avg_delay": "Latency", + "chart_fetch_error_message": "Failed to fetch network data, please check if the server monitoring is enabled" }, "NetworkChart": { "ServerMonitorCount": "Services" diff --git a/messages/ja.json b/messages/ja.json index 7e13beb..e308748 100644 --- a/messages/ja.json +++ b/messages/ja.json @@ -29,7 +29,8 @@ "Offline": "オフライン" }, "NetworkChartClient": { - "avg_delay": "遅延" + "avg_delay": "遅延", + "chart_fetch_error_message": "ネットワークデータの取得に失敗しました。サーバーの監視が有効になっているかどうかを確認してください" }, "NetworkChart": { "ServerMonitorCount": "サービス" diff --git a/messages/zh-t.json b/messages/zh-t.json index 8f754cd..9efe44c 100644 --- a/messages/zh-t.json +++ b/messages/zh-t.json @@ -29,7 +29,8 @@ "Offline": "離線" }, "NetworkChartClient": { - "avg_delay": "延遲" + "avg_delay": "延遲", + "chart_fetch_error_message": "獲取網絡數據失敗,請檢查是否開啟服務端監控" }, "NetworkChart": { "ServerMonitorCount": "個監測服務" diff --git a/messages/zh.json b/messages/zh.json index b7b2652..c573923 100644 --- a/messages/zh.json +++ b/messages/zh.json @@ -29,7 +29,8 @@ "Offline": "离线" }, "NetworkChartClient": { - "avg_delay": "延迟" + "avg_delay": "延迟", + "chart_fetch_error_message": "获取网络数据失败,请检查是否开启服务端监控" }, "NetworkChart": { "ServerMonitorCount": "个监控服务"