feat: separate upload and download traffic display

This commit is contained in:
hamster1963 2024-10-19 21:10:09 +08:00
parent 5f1d84992c
commit 4040c6d83a
3 changed files with 15 additions and 7 deletions

View File

@ -15,7 +15,7 @@ export default function ServerOverviewClient() {
const { data } = useSWR<ServerApi>("/api/server", nezhaFetcher);
const disableCartoon = getEnv("NEXT_PUBLIC_DisableCartoon") === "true";
return (
<section className="grid grid-cols-2 gap-4 md:grid-cols-4">
<section className="grid grid-cols-2 gap-4 lg:grid-cols-4">
<Card>
<CardContent className="px-6 py-3">
<section className="flex flex-col gap-1">
@ -94,9 +94,14 @@ export default function ServerOverviewClient() {
{t("p_3463-3530_Totalbandwidth")}
</p>
{data ? (
<p className="text-lg font-semibold">
{formatBytes(data?.total_bandwidth)}
</p>
<section className="flex pt-[4px] items-center gap-2">
<p className="text-[14px] font-semibold">
{formatBytes(data?.total_out_bandwidth)}
</p>
<p className="text-[14px] font-semibold">
{formatBytes(data?.total_in_bandwidth)}
</p>
</section>
) : (
<div className="flex h-7 items-center">
<Loader visible={true} />

View File

@ -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[];
};

View File

@ -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;