import { useTranslations } from "next-intl"; import { NezhaAPISafe } from "../app/[locale]/types/nezha-api"; import ServerUsageBar from "@/components/ServerUsageBar"; import { Card } from "@/components/ui/card"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { cn, formatNezhaInfo } from "@/lib/utils"; import ServerCardPopover from "./ServerCardPopover"; import getUnicodeFlagIcon from "country-flag-icons/unicode"; import { env } from "next-runtime-env"; export default function ServerCard({ serverInfo, }: { serverInfo: NezhaAPISafe; }) { const t = useTranslations("ServerCard"); const { name, country_code, online, cpu, up, down, mem, stg, ...props } = formatNezhaInfo(serverInfo); const showFlag = env("NEXT_PUBLIC_ShowFlag") === "true"; return online ? (
{showFlag ? ( country_code ? ( {getUnicodeFlagIcon(country_code)} ) : ( 🏁 ) ) : null}

{name}

{" "} {/* 设置固定宽度 */}

{t("CPU")}

{cpu.toFixed(2)}%
{" "} {/* 设置固定宽度 */}

{t("Mem")}

{mem.toFixed(2)}%
{" "} {/* 设置固定宽度 */}

{t("STG")}

{stg.toFixed(2)}%
{" "} {/* 设置固定宽度 */}

{t("Upload")}

{up.toFixed(2)} Mb/s
{" "} {/* 设置固定宽度 */}

{t("Download")}

{down.toFixed(2)} Mb/s
) : (
{showFlag ? ( country_code ? ( {getUnicodeFlagIcon(country_code)} ) : ( 🏁 ) ) : null}

{name}

{t("Offline")}

); }