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 { NezhaServer } from "@/types/nezha-api" import { useTranslation } from "react-i18next" import { useNavigate } from "react-router-dom" import PlanInfo from "./PlanInfo" import BillingInfo from "./billingInfo" import { Card } from "./ui/card" import { Separator } from "./ui/separator" import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./ui/tooltip" 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, cpu_info, mem_total, disk_total, tcp, udp, process } = 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 // @ts-expect-error ShowServerDetails is a global variable const showServerDetails = window.ShowServerDetails !== undefined ? window.ShowServerDetails as boolean : true 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)}
{/* 服务器详细信息标签和 PlanInfo */}
{showServerDetails && ( <> {cpu_info && cpu_info.length > 0 && (

{cpu_info[0].includes("Physical") ? "物理CPU: " : "vCPU: "} {cpu_info[0].match(/(\d+)\s+(?:Physical|Virtual)\s+Core/)?.[1] || "?"}

{cpu_info.join(", ")}
)} {mem_total > 0 && (

{t("serverCard.mem")}: {formatBytes(mem_total)}

)} {disk_total > 0 && (

{t("serverCard.stg")}: {formatBytes(disk_total)}

)} {tcp > 0 && (

TCP: {tcp}

)} {udp > 0 && (

UDP: {udp}

)} {process > 0 && (

{t("serverDetailChart.process")}: {process}

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

{name}

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