From 6b4ba049950b15faa0c1fa48f85844508987bbf6 Mon Sep 17 00:00:00 2001 From: wood chen Date: Fri, 18 Apr 2025 20:49:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20ServerCard=20=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E6=B7=BB=E5=8A=A0=E7=8A=B6=E6=80=81=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E5=92=8C=E9=A2=9C=E8=89=B2=E7=AD=89=E7=BA=A7=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B8=83=E5=B1=80=E5=92=8C=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=BC=BA=E7=BD=91=E7=BB=9C=E5=92=8C=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E4=BD=BF=E7=94=A8=E4=BF=A1=E6=81=AF=E7=9A=84=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=EF=BC=8C=E6=8F=90=E5=8D=87=E7=94=A8=E6=88=B7=E4=BD=93?= =?UTF-8?q?=E9=AA=8C=E5=92=8C=E5=8F=AF=E8=AF=BB=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ServerCard.tsx | 329 +++++++++++++++++++--------------- 1 file changed, 182 insertions(+), 147 deletions(-) diff --git a/src/components/ServerCard.tsx b/src/components/ServerCard.tsx index 7e2994c..e973f76 100644 --- a/src/components/ServerCard.tsx +++ b/src/components/ServerCard.tsx @@ -12,6 +12,7 @@ import BillingInfo from "./billingInfo" import { Badge } from "./ui/badge" import { Card, CardContent, CardHeader, CardFooter } from "./ui/card" import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./ui/tooltip" +import { ArrowDown, ArrowUp, Clock, Cpu, HardDrive, Server, Activity } from "lucide-react" export default function ServerCard({ now, serverInfo }: { now: number; serverInfo: NezhaServer }) { const { t } = useTranslation() @@ -73,33 +74,43 @@ export default function ServerCard({ now, serverInfo }: { now: number; serverInf : `${(speed * 1024).toFixed(2)}K/s` } + // 获取颜色等级 + const getColorClass = (value: number) => { + if (value > 90) return "text-red-500" + if (value > 70) return "text-orange-400" + return "text-green-500" + } + if (!online) { return ( +
- + {showFlag && }

{name}

- {parsedData?.billingDataMod && ( -
- -
- )} - - {parsedData?.planDataMod && ( -
- -
- )} +
+ {parsedData?.billingDataMod && ( +
+ +
+ )} + + {parsedData?.planDataMod && ( +
+ +
+ )} +
) @@ -108,126 +119,155 @@ export default function ServerCard({ now, serverInfo }: { now: number; serverInf return ( +
+ -
- - {showFlag && } -

{name}

-
- - {parsedData?.billingDataMod && ( -
- -
- )} -
- - - {/* 系统信息和资源使用情况 */} -
- {/* 系统信息 */} -
-
- {platform.includes("Windows") ? ( - - ) : ( -

- )} -

- - {platform.includes("Windows") ? "Windows" : GetOsName(platform)} - +
+
+ + {showFlag && } +

{name}

- {/* 资源使用情况 */} -
- {/* CPU使用率 */} -
-
- CPU - {cpu.toFixed(0)}% -
- +
+
+ {platform.includes("Windows") ? ( + + ) : ( + + )} + {platform.includes("Windows") ? "Windows" : GetOsName(platform)}
- - {/* 内存使用率 */} -
-
- {t("serverCard.mem")} - {mem.toFixed(0)}% -
- +
+
+ +
+ {parsedData?.billingDataMod && ( +
+
- - {/* 存储使用率 */} -
-
- {t("serverCard.stg")} - {stg.toFixed(0)}% -
- + )} + + {uptime > 0 && ( +
+ + {formatUptime(uptime, t)}
- - {/* 网络上传 */} -
-
- {t("serverCard.upload")} - {formatSpeed(up)} -
-
-
+ )} +
+ + + + {/* 主要资源使用情况 - 全新设计 */} +
+ {/* CPU使用率 */} +
+
+
+ + CPU
+ + {cpu.toFixed(0)}% +
- - {/* 网络下载 */} -
-
- {t("serverCard.download")} - {formatSpeed(down)} -
-
-
+ +
+ + {/* 内存使用率 */} +
+
+
+
+ + + + + + + +
+ {t("serverCard.mem")}
+ + {mem.toFixed(0)}% +
+ +
+ + {/* 存储使用率 */} +
+
+
+ + {t("serverCard.stg")} +
+ + {stg.toFixed(0)}% + +
+ +
+
+ + {/* 网络使用情况 */} +
+ {/* 网络速率 */} +
+
+
+ + {t("serverCard.upload")} +
+ {formatSpeed(up)} +
+
+
+ + {t("serverCard.download")} +
+ {formatSpeed(down)} +
+
+ + {/* 连接数与进程数 */} +
+ {tcp > 0 && ( +
+ + TCP: {tcp} +
+ )} + {udp > 0 && ( +
+ + UDP: {udp} +
+ )} + {process > 0 && ( +
+ + {t("serverDetailChart.process")}: {process} +
+ )}
{/* 服务器详细信息区域 */} {showServerDetails && ( -
- {/* 运行时间 */} - {uptime > 0 && ( - - - - - {t("serverCard.uptime")}: {formatUptime(uptime, t)} - - - - {t("serverCard.uptime")}: {formatUptime(uptime, t)} - - - - )} - +
{/* CPU信息 */} {cpu_info && cpu_info.length > 0 && ( - + {cpu_info[0].includes("Physical") ? "pCPU: " : "vCPU: "} {cpu_info[0].match(/(\d+)\s+(?:Physical|Virtual)\s+Core/)?.[1] || "?"} @@ -241,68 +281,63 @@ export default function ServerCard({ now, serverInfo }: { now: number; serverInf {/* 内存大小 */} {mem_total > 0 && ( - + {t("serverCard.mem")}: {formatBytes(mem_total)} )} {/* 存储大小 */} {disk_total > 0 && ( - + {t("serverCard.stg")}: {formatBytes(disk_total)} )} - - {/* TCP连接数 */} - {tcp > 0 && ( - - TCP: {tcp} - - )} - - {/* UDP连接数 */} - {udp > 0 && ( - - UDP: {udp} - - )} - - {/* 进程数 */} - {process > 0 && ( - - {t("serverDetailChart.process")}: {process} - - )}
)} - + {/* 套餐信息 */} {parsedData?.planDataMod && ( -
+
)} {/* 网络传输信息 */} {showNetTransfer && ( -
- - {t("serverCard.upload")}: {formatBytes(net_out_transfer)} - - - {t("serverCard.download")}: {formatBytes(net_in_transfer)} - +
+
+
+ + {t("serverCard.upload")} +
+ {formatBytes(net_out_transfer)} +
+
+
+ + {t("serverCard.download")} +
+ {formatBytes(net_in_transfer)} +
)} + + {/* 视觉元素:左侧状态条 */} + ) }