import { useTranslation } from "react-i18next"; import { useNavigate } from "react-router-dom"; import ServerFlag from "@/components/ServerFlag"; import ServerUsageBar from "@/components/ServerUsageBar"; import { formatBytes } from "@/lib/format"; import { GetFontLogoClass, GetOsName, MageMicrosoftWindows, } from "@/lib/logo-class"; import { cn, formatNezhaInfo, parsePublicNote } from "@/lib/utils"; import type { NezhaServer } from "@/types/nezha-api"; import BillingInfo from "./billingInfo"; import PlanInfo from "./PlanInfo"; import { Card } from "./ui/card"; import { Separator } from "./ui/separator"; export default function ServerCardInline({ now, serverInfo, }: { now: number; serverInfo: NezhaServer; }) { const { t } = useTranslation(); const navigate = useNavigate(); const { name, country_code, online, cpu, up, down, mem, stg, platform, uptime, net_in_transfer, net_out_transfer, public_note, } = formatNezhaInfo(now, serverInfo); const cardClick = () => { sessionStorage.setItem("fromMainPage", "true"); navigate(`/server/${serverInfo.id}`); }; const showFlag = true; const customBackgroundImage = (window.CustomBackgroundImage as string) !== "" ? window.CustomBackgroundImage : undefined; const parsedData = parsePublicNote(public_note); return online ? (
{showFlag ? : null}

{name}

{parsedData?.billingDataMod && ( )}
{platform.includes("Windows") ? ( ) : (

)}

{t("serverCard.system")}

{platform.includes("Windows") ? "Windows" : GetOsName(platform)}

{t("serverCard.uptime")}

{uptime / 86400 >= 1 ? `${(uptime / 86400).toFixed(0)} ${t("serverCard.days")}` : `${(uptime / 3600).toFixed(0)} ${t("serverCard.hours")}`}

{"CPU"}

{cpu.toFixed(2)}%

{t("serverCard.mem")}

{mem.toFixed(2)}%

{t("serverCard.stg")}

{stg.toFixed(2)}%

{t("serverCard.upload")}

{up >= 1024 ? `${(up / 1024).toFixed(2)}G/s` : up >= 1 ? `${up.toFixed(2)}M/s` : `${(up * 1024).toFixed(2)}K/s`}

{t("serverCard.download")}

{down >= 1024 ? `${(down / 1024).toFixed(2)}G/s` : down >= 1 ? `${down.toFixed(2)}M/s` : `${(down * 1024).toFixed(2)}K/s`}

{t("serverCard.totalUpload")}

{formatBytes(net_out_transfer)}

{t("serverCard.totalDownload")}

{formatBytes(net_in_transfer)}
{parsedData?.planDataMod && }
) : (
{showFlag ? : null}

{name}

{parsedData?.billingDataMod && ( )}
{parsedData?.planDataMod && }
); }