import type { 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 { GetFontLogoClass, GetOsName, MageMicrosoftWindows } from "@/lib/logo-class" import { cn, formatBytes, formatNezhaInfo } from "@/lib/utils" import { useTranslations } from "next-intl" import Link from "next/link" 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) const showFlag = getEnv("NEXT_PUBLIC_ShowFlag") === "true" const showNetTransfer = getEnv("NEXT_PUBLIC_ShowNetTransfer") === "true" const fixedTopServerName = getEnv("NEXT_PUBLIC_FixedTopServerName") === "true" const saveSession = () => { sessionStorage.setItem("fromMainPage", "true") } return online ? ( {showFlag ? : null} {name} {fixedTopServerName && ( {host.Platform.includes("Windows") ? ( ) : ( )} {t("System")} {host.Platform.includes("Windows") ? "Windows" : GetOsName(host.Platform)} )} {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 && ( {t("Upload")}:{formatBytes(serverInfo.status.NetOutTransfer)} {t("Download")}:{formatBytes(serverInfo.status.NetInTransfer)} )} ) : ( {showFlag ? : null} {name} ) }
{name}
{t("System")}
{t("CPU")}
{t("Mem")}
{t("STG")}
{t("Upload")}
{t("Download")}