From 170315adbc2828ee3055a6564d7837de2e2d76db Mon Sep 17 00:00:00 2001 From: yeyang <746659424@qq.com> Date: Fri, 12 Apr 2024 23:20:12 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20=E7=8B=AC=E7=AB=8B=E7=BD=91?= =?UTF-8?q?=E7=BB=9C=E9=80=9F=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/State/Monitor.js | 21 +++++++++++++-------- model/State/OtherInfo.js | 3 --- model/State/index.js | 3 ++- resources/state/state.html | 19 +++++++++++++++---- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/model/State/Monitor.js b/model/State/Monitor.js index fa56c7c..39d262b 100644 --- a/model/State/Monitor.js +++ b/model/State/Monitor.js @@ -125,16 +125,21 @@ export default new class monitor { * @returns {object} */ get getNetwork() { - let network = _.cloneDeep(this.network)?.[0] - if (!network || network.rx_sec == null || network.tx_sec == null) { + let network = _.cloneDeep(this.network) + if (!network || network.length === 0) { return false } - network.rx_sec = getFileSize(network.rx_sec, false, false) - network.tx_sec = getFileSize(network.tx_sec, false, false) - // return network - return { - first: network.iface, - tail: `↑${network.tx_sec}/s | ↓${network.rx_sec}/s` + let data = [] + for (let v of network) { + if (v.rx_sec != null && v.tx_sec != null) { + let _rx = getFileSize(v.rx_sec, false, false) + let _tx = getFileSize(v.tx_sec, false, false) + data.push({ + first: v.iface, + tail: `↑${_tx}/s | ↓${_rx}/s` + }) + } } + return data.length === 0 ? false : data } }() diff --git a/model/State/OtherInfo.js b/model/State/OtherInfo.js index 72b34f4..a3fd89e 100644 --- a/model/State/OtherInfo.js +++ b/model/State/OtherInfo.js @@ -2,7 +2,6 @@ import _ from "lodash" import { osInfo } from "./DependencyChecker.js" import { formatDuration } from "../../tools/index.js" import os from "os" -import Monitor from "./Monitor.js" import fs from "fs" import { Version } from "../../components/index.js" @@ -13,8 +12,6 @@ export default function otherInfi() { first: "系统", tail: osInfo?.distro }) - // 网络 - otherInfo.push(Monitor.getNetwork) // 插件数量 otherInfo.push({ first: "插件", diff --git a/model/State/index.js b/model/State/index.js index 08778c8..af3d3b5 100644 --- a/model/State/index.js +++ b/model/State/index.js @@ -52,7 +52,8 @@ export async function getData(e) { // 硬盘速率 fsStats: Monitor.DiskSpeed, copyright: getCopyright(), - isBotIndex + isBotIndex, + network: Monitor.getNetwork } } diff --git a/resources/state/state.html b/resources/state/state.html index ba955e2..b030c0f 100644 --- a/resources/state/state.html +++ b/resources/state/state.html @@ -99,10 +99,9 @@ -{{/if}} -{{if otherInfo}} -
- {{each otherInfo}} +{{if network}} +
+ {{each network}}

{{$value.first}}

{{@$value.tail}}

@@ -122,6 +121,18 @@
{{/if}} +{{/if}} +{{if otherInfo}} +
+ {{each otherInfo}} +
+

{{$value.first}}

+

{{@$value.tail}}

+
+ {{/each}} +
+{{/if}} + {{@FastFetch}} {{/block}} \ No newline at end of file