import { NezhaAPISafe } from "@/app/types/nezha-api"; import ServerFlag from "@/components/ServerFlag"; import ServerUsageBar from "@/components/ServerUsageBar"; import { Badge } from "@/components/ui/badge"; import { Card } from "@/components/ui/card"; import getEnv from "@/lib/env-entry"; import { cn, formatBytes, formatNezhaInfo } from "@/lib/utils"; import { useTranslations } from "next-intl"; import Link from "next/link"; import { useRouter } from "next/navigation"; export default function ServerCard({ serverInfo, }: { serverInfo: NezhaAPISafe; }) { const t = useTranslations("ServerCard"); const router = useRouter(); const { id, name, country_code, online, cpu, up, down, mem, stg } = formatNezhaInfo(serverInfo); const showFlag = getEnv("NEXT_PUBLIC_ShowFlag") === "true"; const showNetTransfer = getEnv("NEXT_PUBLIC_ShowNetTransfer") === "true"; const fixedTopServerName = getEnv("NEXT_PUBLIC_FixedTopServerName") === "true"; return online ? ( {showFlag ? : null} {name} {t("CPU")} {cpu.toFixed(2)}% {t("Mem")} {mem.toFixed(2)}% {t("STG")} {stg.toFixed(2)}% {t("Upload")} {up >= 1024 ? `${(up / 1024).toFixed(2)}G/s` : `${up.toFixed(2)}M/s`} {t("Download")} {down >= 1024 ? `${(down / 1024).toFixed(2)}G/s` : `${down.toFixed(2)}M/s`} {showNetTransfer && ( { router.push(`/${id}`); }} className={"flex items-center justify-between gap-1"} > {t("Upload")}:{formatBytes(serverInfo.status.NetOutTransfer)} {t("Download")}:{formatBytes(serverInfo.status.NetInTransfer)} )} ) : ( {showFlag ? : null} {name} ); }
{name}
{t("CPU")}
{t("Mem")}
{t("STG")}
{t("Upload")}
{t("Download")}