From 5e8e498be3cfff3c23c898cc7e4af44a2341ef5f Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Sat, 27 Jul 2024 12:19:17 +0800 Subject: [PATCH] fix: fix server status error --- app/(main)/ClientComponents/ServerListClient.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/(main)/ClientComponents/ServerListClient.tsx b/app/(main)/ClientComponents/ServerListClient.tsx index 3dbfcfd..66b72f8 100644 --- a/app/(main)/ClientComponents/ServerListClient.tsx +++ b/app/(main)/ClientComponents/ServerListClient.tsx @@ -3,6 +3,7 @@ import ServerCard from "@/components/ServerCard"; import { nezhaFetcher } from "@/lib/utils"; import useSWR from "swr"; +import { DateTime } from "luxon"; export default function ServerListClient() { const { data } = useSWR('/api/server', nezhaFetcher, { @@ -22,7 +23,7 @@ export default function ServerListClient() { name={server.name} up={server.status.NetOutSpeed / 1024 / 1024} down={server.status.NetInSpeed / 1024 / 1024} - status={server.status.Uptime > 0 ? "online" : "offline"} + status={DateTime.now().toUnixInteger() - server.last_active > 300 ? "offline" : "online"} uptime={server.status.Uptime / 86400} mem={(server.status.MemUsed / server.host.MemTotal) * 100} stg={server.status.DiskUsed / server.host.DiskTotal}