From 606237d57e7b1996673762a5bc2ac9cc1ee15076 Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Thu, 24 Oct 2024 15:33:59 +0800 Subject: [PATCH] perf: use Link prefetch --- components/ServerCard.tsx | 170 +++++++++++++++++++------------------- 1 file changed, 85 insertions(+), 85 deletions(-) diff --git a/components/ServerCard.tsx b/components/ServerCard.tsx index ff07e5c..19e850d 100644 --- a/components/ServerCard.tsx +++ b/components/ServerCard.tsx @@ -12,6 +12,7 @@ import { import getEnv from "@/lib/env-entry"; import { cn, formatBytes, formatNezhaInfo } from "@/lib/utils"; import { useLocale, useTranslations } from "next-intl"; +import Link from "next/link"; import { useRouter } from "next/navigation"; export default function ServerCard({ @@ -31,95 +32,94 @@ export default function ServerCard({ const locale = useLocale(); return online ? ( - { - router.push(`/${locale}/${id}`); - }} - > -
+ - -
- {showFlag ? : null} -
-

- {name} -

-
-
-
-
-

{t("CPU")}

-
- {cpu.toFixed(2)}% -
- -
-
-

{t("Mem")}

-
- {mem.toFixed(2)}% -
- -
-
-

{t("STG")}

-
- {stg.toFixed(2)}% -
- -
-
-

{t("Upload")}

-
- {up.toFixed(2)}M/s -
-
-
-

{t("Download")}

-
- {down.toFixed(2)}M/s -
-
-
- {showNetTransfer && ( -
{ - router.push(`/${locale}/network/${id}`); - }} - className={"flex items-center justify-between gap-1"} + +
- - {t("Upload")}:{formatBytes(serverInfo.status.NetOutTransfer)} - - - {t("Download")}:{formatBytes(serverInfo.status.NetInTransfer)} - + {showFlag ? : null} +
+

+ {name} +

+
+
+
+
+

{t("CPU")}

+
+ {cpu.toFixed(2)}% +
+ +
+
+

{t("Mem")}

+
+ {mem.toFixed(2)}% +
+ +
+
+

{t("STG")}

+
+ {stg.toFixed(2)}% +
+ +
+
+

{t("Upload")}

+
+ {up.toFixed(2)}M/s +
+
+
+

{t("Download")}

+
+ {down.toFixed(2)}M/s +
+
- )} -
- + {showNetTransfer && ( +
{ + router.push(`/${locale}/network/${id}`); + }} + className={"flex items-center justify-between gap-1"} + > + + {t("Upload")}:{formatBytes(serverInfo.status.NetOutTransfer)} + + + {t("Download")}:{formatBytes(serverInfo.status.NetInTransfer)} + +
+ )} +
+
+ ) : (