From a8358e04e4e49d74e00e42847cacda5398ce08d5 Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Sun, 20 Oct 2024 00:36:30 +0800 Subject: [PATCH] fix: init chart --- .../ServerDetailChartClient.tsx | 50 +++++++++++++++---- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/app/[locale]/(main)/ClientComponents/ServerDetailChartClient.tsx b/app/[locale]/(main)/ClientComponents/ServerDetailChartClient.tsx index 4afc4b0c..4edf4b7e 100644 --- a/app/[locale]/(main)/ClientComponents/ServerDetailChartClient.tsx +++ b/app/[locale]/(main)/ClientComponents/ServerDetailChartClient.tsx @@ -104,7 +104,10 @@ function CpuChart({ data }: { data: NezhaAPISafe }) { const timestamp = Date.now().toString(); let newData = [] as cpuChartData[]; if (cpuChartData.length === 0) { - newData = [{ timeStamp: timestamp, cpu: cpu }, { timeStamp: timestamp, cpu: cpu }]; + newData = [ + { timeStamp: timestamp, cpu: cpu }, + { timeStamp: timestamp, cpu: cpu }, + ]; } else { newData = [...cpuChartData, { timeStamp: timestamp, cpu: cpu }]; } @@ -201,9 +204,15 @@ function ProcessChart({ data }: { data: NezhaAPISafe }) { const timestamp = Date.now().toString(); let newData = [] as processChartData[]; if (processChartData.length === 0) { - newData = [{ timeStamp: timestamp, process: process }, { timeStamp: timestamp, process: process }]; + newData = [ + { timeStamp: timestamp, process: process }, + { timeStamp: timestamp, process: process }, + ]; } else { - newData = [...processChartData, { timeStamp: timestamp, process: process }]; + newData = [ + ...processChartData, + { timeStamp: timestamp, process: process }, + ]; } if (newData.length > 30) { newData.shift(); @@ -285,9 +294,15 @@ function MemChart({ data }: { data: NezhaAPISafe }) { const timestamp = Date.now().toString(); let newData = [] as memChartData[]; if (memChartData.length === 0) { - newData = [{ timeStamp: timestamp, mem: mem, swap: swap }, { timeStamp: timestamp, mem: mem, swap: swap }]; + newData = [ + { timeStamp: timestamp, mem: mem, swap: swap }, + { timeStamp: timestamp, mem: mem, swap: swap }, + ]; } else { - newData = [...memChartData, { timeStamp: timestamp, mem: mem, swap: swap }]; + newData = [ + ...memChartData, + { timeStamp: timestamp, mem: mem, swap: swap }, + ]; } if (newData.length > 30) { newData.shift(); @@ -406,7 +421,10 @@ function DiskChart({ data }: { data: NezhaAPISafe }) { const timestamp = Date.now().toString(); let newData = [] as diskChartData[]; if (diskChartData.length === 0) { - newData = [{ timeStamp: timestamp, disk: disk }, { timeStamp: timestamp, disk: disk }]; + newData = [ + { timeStamp: timestamp, disk: disk }, + { timeStamp: timestamp, disk: disk }, + ]; } else { newData = [...diskChartData, { timeStamp: timestamp, disk: disk }]; } @@ -503,9 +521,15 @@ function NetworkChart({ data }: { data: NezhaAPISafe }) { const timestamp = Date.now().toString(); let newData = [] as networkChartData[]; if (networkChartData.length === 0) { - newData = [{ timeStamp: timestamp, upload: up, download: down }, { timeStamp: timestamp, upload: up, download: down }]; + newData = [ + { timeStamp: timestamp, upload: up, download: down }, + { timeStamp: timestamp, upload: up, download: down }, + ]; } else { - newData = [...networkChartData, { timeStamp: timestamp, upload: up, download: down }]; + newData = [ + ...networkChartData, + { timeStamp: timestamp, upload: up, download: down }, + ]; } if (newData.length > 30) { newData.shift(); @@ -623,9 +647,15 @@ function ConnectChart({ data }: { data: NezhaAPISafe }) { const timestamp = Date.now().toString(); let newData = [] as connectChartData[]; if (connectChartData.length === 0) { - newData = [{ timeStamp: timestamp, tcp: tcp, udp: udp }, { timeStamp: timestamp, tcp: tcp, udp: udp }]; + newData = [ + { timeStamp: timestamp, tcp: tcp, udp: udp }, + { timeStamp: timestamp, tcp: tcp, udp: udp }, + ]; } else { - newData = [...connectChartData, { timeStamp: timestamp, tcp: tcp, udp: udp }]; + newData = [ + ...connectChartData, + { timeStamp: timestamp, tcp: tcp, udp: udp }, + ]; } if (newData.length > 30) { newData.shift();