💄 独立网络速率

This commit is contained in:
yeyang
2024-04-12 23:20:12 +08:00
parent fed691b281
commit 170315adbc
4 changed files with 30 additions and 16 deletions

View File

@@ -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
}
}()

View File

@@ -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: "插件",

View File

@@ -52,7 +52,8 @@ export async function getData(e) {
// 硬盘速率
fsStats: Monitor.DiskSpeed,
copyright: getCopyright(),
isBotIndex
isBotIndex,
network: Monitor.getNetwork
}
}

View File

@@ -99,10 +99,9 @@
<script src="{{_res_path}}state/state_chart.js"></script>
</div>
{{/if}}
{{if otherInfo}}
<div class="box" data-boxInfo="其他">
{{each otherInfo}}
{{if network}}
<div class="box" data-boxInfo="网络速率">
{{each network}}
<div class="speed">
<p>{{$value.first}}</p>
<p>{{@$value.tail}}</p>
@@ -122,6 +121,18 @@
</div>
{{/if}}
{{/if}}
{{if otherInfo}}
<div class="box" data-boxInfo="其他">
{{each otherInfo}}
<div class="speed">
<p>{{$value.first}}</p>
<p>{{@$value.tail}}</p>
</div>
{{/each}}
</div>
{{/if}}
{{@FastFetch}}
{{/block}}