From 7145d4ca0734649b40f5cd29e5d3547eb9fd6f2f Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Fri, 1 Sep 2023 16:42:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E6=A6=82=E8=A7=88?= =?UTF-8?q?=E9=A1=B5=E6=B5=81=E9=87=8F=E7=AA=81=E5=A2=9E=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#2142)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #2073 --- frontend/src/views/home/index.vue | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/frontend/src/views/home/index.vue b/frontend/src/views/home/index.vue index b08f166ed..7a300d9da 100644 --- a/frontend/src/views/home/index.vue +++ b/frontend/src/views/home/index.vue @@ -374,9 +374,10 @@ const onLoadCurrentInfo = async () => { const res = await loadCurrentInfo(searchInfo.ioOption, searchInfo.netOption); currentInfo.value.timeSinceUptime = res.data.timeSinceUptime; + let timeInterval = Number(res.data.uptime - currentInfo.value.uptime) || 3; currentChartInfo.netBytesSent = res.data.netBytesSent - currentInfo.value.netBytesSent > 0 - ? Number(((res.data.netBytesSent - currentInfo.value.netBytesSent) / 1024 / 3).toFixed(2)) + ? Number(((res.data.netBytesSent - currentInfo.value.netBytesSent) / 1024 / timeInterval).toFixed(2)) : 0; netBytesSents.value.push(currentChartInfo.netBytesSent); if (netBytesSents.value.length > 20) { @@ -385,7 +386,7 @@ const onLoadCurrentInfo = async () => { currentChartInfo.netBytesRecv = res.data.netBytesRecv - currentInfo.value.netBytesRecv > 0 - ? Number(((res.data.netBytesRecv - currentInfo.value.netBytesRecv) / 1024 / 3).toFixed(2)) + ? Number(((res.data.netBytesRecv - currentInfo.value.netBytesRecv) / 1024 / timeInterval).toFixed(2)) : 0; netBytesRecvs.value.push(currentChartInfo.netBytesRecv); if (netBytesRecvs.value.length > 20) { @@ -394,7 +395,7 @@ const onLoadCurrentInfo = async () => { currentChartInfo.ioReadBytes = res.data.ioReadBytes - currentInfo.value.ioReadBytes > 0 - ? Number(((res.data.ioReadBytes - currentInfo.value.ioReadBytes) / 1024 / 1024 / 3).toFixed(2)) + ? Number(((res.data.ioReadBytes - currentInfo.value.ioReadBytes) / 1024 / 1024 / timeInterval).toFixed(2)) : 0; ioReadBytes.value.push(currentChartInfo.ioReadBytes); if (ioReadBytes.value.length > 20) { @@ -403,17 +404,17 @@ const onLoadCurrentInfo = async () => { currentChartInfo.ioWriteBytes = res.data.ioWriteBytes - currentInfo.value.ioWriteBytes > 0 - ? Number(((res.data.ioWriteBytes - currentInfo.value.ioWriteBytes) / 1024 / 1024 / 3).toFixed(2)) + ? Number(((res.data.ioWriteBytes - currentInfo.value.ioWriteBytes) / 1024 / 1024 / timeInterval).toFixed(2)) : 0; ioWriteBytes.value.push(currentChartInfo.ioWriteBytes); if (ioWriteBytes.value.length > 20) { ioWriteBytes.value.splice(0, 1); } - currentChartInfo.ioCount = Math.round(Number((res.data.ioCount - currentInfo.value.ioCount) / 3)); + currentChartInfo.ioCount = Math.round(Number((res.data.ioCount - currentInfo.value.ioCount) / timeInterval)); let ioReadTime = res.data.ioReadTime - currentInfo.value.ioReadTime; let ioWriteTime = res.data.ioWriteTime - currentInfo.value.ioWriteTime; let ioChoose = ioReadTime > ioWriteTime ? ioReadTime : ioWriteTime; - currentChartInfo.ioTime = Math.round(Number(ioChoose / 3)); + currentChartInfo.ioTime = Math.round(Number(ioChoose / timeInterval)); timeIODatas.value.push(dateFormatForSecond(res.data.shotTime)); if (timeIODatas.value.length > 20) {