From 2d894409a0c9207704faf94f2be7e30aab71f7bf Mon Sep 17 00:00:00 2001
From: yeyang <746659424@qq.com>
Date: Sun, 4 Dec 2022 18:56:26 +0800
Subject: [PATCH] =?UTF-8?q?=E7=8A=B6=E6=80=81=E8=B6=85=E8=BF=87=E4=B8=80?=
=?UTF-8?q?=E5=AE=9A=E5=80=BC=E5=8F=98=E6=8D=A2=E9=A2=9C=E8=89=B2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
apps/state.js | 8 +++++++-
model/CPU.js | 14 ++++++++++----
resources/state/state.html | 5 -----
3 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/apps/state.js b/apps/state.js
index 71b96d3..4e9a450 100644
--- a/apps/state.js
+++ b/apps/state.js
@@ -104,12 +104,18 @@ export class example extends plugin {
if (!i.size || !i.used || !i.available) continue;
if (/docker/.test(i.mount)) continue;
if (osinfo.arch.includes("arm") && i.mount != '/' && !/darwin/i.test(osinfo.platform)) continue;
+ let color = '#90ee90'
+ if (i.use > 90) {
+ color = '#d73403'
+ } else if (i.use > 80) {
+ color = '#ffa500'
+ }
HardDisk +=
`
${i.mount}
${CPU.getfilesize(i.used)} / ${CPU.getfilesize(i.size)}
-
+
${Math.ceil(i.use)}%
`
diff --git a/model/CPU.js b/model/CPU.js
index ab2da8e..5648e17 100644
--- a/model/CPU.js
+++ b/model/CPU.js
@@ -109,12 +109,18 @@ class OSUtils {
*/
Circle(res) {
let num = (res * 360).toFixed(0)
- let leftCircle = `style=transform:rotate(-180deg)`;
- let rightCircle;
+ let color = '#90ee90'
+ if (res > 0.9) {
+ color = '#d73403'
+ } else if (res > 0.8) {
+ color = '#ffa500'
+ }
+ let leftCircle = `style=transform:rotate(-180deg);background:${color};`;
+ let rightCircle = `style=background:${color};`
if (num > 180) {
- leftCircle = `style=transform:rotate(${num}deg)`
+ leftCircle = `style=transform:rotate(${num}deg);background:${color};`
} else {
- rightCircle = `style=transform:rotate(-${180 - num}deg)`;
+ rightCircle = `style=transform:rotate(-${180 - num}deg);background:${color};`;
}
return [leftCircle, rightCircle]
}
diff --git a/resources/state/state.html b/resources/state/state.html
index e92b75e..9aef3af 100644
--- a/resources/state/state.html
+++ b/resources/state/state.html
@@ -2,11 +2,6 @@
{{block 'css'}}
-
{{/block}}
{{block 'main'}}