From 4040c6d83a5853e1fd87791c21efbea4b7b4aaa6 Mon Sep 17 00:00:00 2001
From: hamster1963 <1410514192@qq.com>
Date: Sat, 19 Oct 2024 21:10:09 +0800
Subject: [PATCH] feat: separate upload and download traffic display
---
.../ClientComponents/ServerOverviewClient.tsx | 13 +++++++++----
app/[locale]/types/nezha-api.ts | 3 ++-
lib/serverFetch.tsx | 6 ++++--
3 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/app/[locale]/(main)/ClientComponents/ServerOverviewClient.tsx b/app/[locale]/(main)/ClientComponents/ServerOverviewClient.tsx
index a4ebb7e..4cd6c81 100644
--- a/app/[locale]/(main)/ClientComponents/ServerOverviewClient.tsx
+++ b/app/[locale]/(main)/ClientComponents/ServerOverviewClient.tsx
@@ -15,7 +15,7 @@ export default function ServerOverviewClient() {
const { data } = useSWR("/api/server", nezhaFetcher);
const disableCartoon = getEnv("NEXT_PUBLIC_DisableCartoon") === "true";
return (
-
+
@@ -94,9 +94,14 @@ export default function ServerOverviewClient() {
{t("p_3463-3530_Totalbandwidth")}
{data ? (
-
- {formatBytes(data?.total_bandwidth)}
-
+
+
+ ↑{formatBytes(data?.total_out_bandwidth)}
+
+
+ ↓{formatBytes(data?.total_in_bandwidth)}
+
+
) : (
diff --git a/app/[locale]/types/nezha-api.ts b/app/[locale]/types/nezha-api.ts
index ecfb986..899809a 100644
--- a/app/[locale]/types/nezha-api.ts
+++ b/app/[locale]/types/nezha-api.ts
@@ -1,7 +1,8 @@
export type ServerApi = {
live_servers: number;
offline_servers: number;
- total_bandwidth: number;
+ total_out_bandwidth: number;
+ total_in_bandwidth: number;
result: NezhaAPISafe[];
};
diff --git a/lib/serverFetch.tsx b/lib/serverFetch.tsx
index c41622c..480bd5a 100644
--- a/lib/serverFetch.tsx
+++ b/lib/serverFetch.tsx
@@ -36,7 +36,8 @@ export async function GetNezhaData() {
const data: ServerApi = {
live_servers: 0,
offline_servers: 0,
- total_bandwidth: 0,
+ total_out_bandwidth: 0,
+ total_in_bandwidth: 0,
result: [],
};
@@ -61,7 +62,8 @@ export async function GetNezhaData() {
data.live_servers += 1;
element.online_status = true;
}
- data.total_bandwidth += element.status.NetOutTransfer;
+ data.total_out_bandwidth += element.status.NetOutTransfer;
+ data.total_in_bandwidth += element.status.NetInTransfer;
delete element.ipv4;
delete element.ipv6;