From 3a848428c3910920497c19671fe1e665de652acc Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Wed, 10 May 2023 10:52:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BF=BD=E7=95=A5=E6=A6=82=E8=A7=88?= =?UTF-8?q?=E9=A1=B5=E5=BC=82=E5=B8=B8=E6=95=B0=E6=8D=AE=20(#971)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/home/index.vue | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/frontend/src/views/home/index.vue b/frontend/src/views/home/index.vue index 428b4c8bb..3d79a008a 100644 --- a/frontend/src/views/home/index.vue +++ b/frontend/src/views/home/index.vue @@ -368,31 +368,37 @@ const onLoadCurrentInfo = async () => { const res = await loadCurrentInfo(searchInfo.ioOption, searchInfo.netOption); currentInfo.value.timeSinceUptime = res.data.timeSinceUptime; - currentChartInfo.netBytesSent = Number( - ((res.data.netBytesSent - currentInfo.value.netBytesSent) / 1024 / 3).toFixed(2), - ); + currentChartInfo.netBytesSent = + res.data.netBytesSent - currentInfo.value.netBytesSent > 0 + ? Number(((res.data.netBytesSent - currentInfo.value.netBytesSent) / 1024 / 3).toFixed(2)) + : 0; netBytesSents.value.push(currentChartInfo.netBytesSent); if (netBytesSents.value.length > 20) { netBytesSents.value.splice(0, 1); } - currentChartInfo.netBytesRecv = Number( - ((res.data.netBytesRecv - currentInfo.value.netBytesRecv) / 1024 / 3).toFixed(2), - ); + + currentChartInfo.netBytesRecv = + res.data.netBytesRecv - currentInfo.value.netBytesRecv > 0 + ? Number(((res.data.netBytesRecv - currentInfo.value.netBytesRecv) / 1024 / 3).toFixed(2)) + : 0; netBytesRecvs.value.push(currentChartInfo.netBytesRecv); if (netBytesRecvs.value.length > 20) { netBytesRecvs.value.splice(0, 1); } - currentChartInfo.ioReadBytes = Number( - ((res.data.ioReadBytes - currentInfo.value.ioReadBytes) / 1024 / 1024 / 3).toFixed(2), - ); + currentChartInfo.ioReadBytes = + res.data.ioReadBytes - currentInfo.value.ioReadBytes > 0 + ? Number(((res.data.ioReadBytes - currentInfo.value.ioReadBytes) / 1024 / 1024 / 3).toFixed(2)) + : 0; ioReadBytes.value.push(currentChartInfo.ioReadBytes); if (ioReadBytes.value.length > 20) { ioReadBytes.value.splice(0, 1); } - currentChartInfo.ioWriteBytes = Number( - ((res.data.ioWriteBytes - currentInfo.value.ioWriteBytes) / 1024 / 1024 / 3).toFixed(2), - ); + + currentChartInfo.ioWriteBytes = + res.data.ioWriteBytes - currentInfo.value.ioWriteBytes > 0 + ? Number(((res.data.ioWriteBytes - currentInfo.value.ioWriteBytes) / 1024 / 1024 / 3).toFixed(2)) + : 0; ioWriteBytes.value.push(currentChartInfo.ioWriteBytes); if (ioWriteBytes.value.length > 20) { ioWriteBytes.value.splice(0, 1);