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, formatNetworkSpeed } 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 formattedUpSpeed = formatNetworkSpeed(up); const formattedDownSpeed = formatNetworkSpeed(down); 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")} {formattedUpSpeed.value} {formattedUpSpeed.unit} {" "} {/* 设置固定宽度 */} {t("Download")} {formattedDownSpeed.value} {formattedDownSpeed.unit} ) : ( {showFlag ? ( country_code ? ( {getUnicodeFlagIcon(country_code)} ) : ( 🏁 ) ) : null} {name} {t("Offline")} ); }
{name}
{t("CPU")}
{t("Mem")}
{t("STG")}
{t("Upload")}
{t("Download")}
{t("Offline")}