状态超过一定值变换颜色

This commit is contained in:
yeyang
2022-12-04 18:56:26 +08:00
parent 1829374d96
commit 2d894409a0
3 changed files with 17 additions and 10 deletions

View File

@@ -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 +=
`<li class='HardDisk_li'>
<div class='word mount'>${i.mount}</div>
<div class='progress'>
<div class='word'>${CPU.getfilesize(i.used)} / ${CPU.getfilesize(i.size)}</div>
<div class='current' style=width:${Math.ceil(i.use)}%></div>
<div class='current' style=width:${Math.ceil(i.use)}%;background:${color}></div>
</div>
<div class='percentage'>${Math.ceil(i.use)}%</div>
</li>`

View File

@@ -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]
}

View File

@@ -2,11 +2,6 @@
{{block 'css'}}
<link rel="stylesheet" href="{{dz}}\plugins\yenai-plugin\resources\state\state.css">
<style>
.current {
width: 75%;
}
</style>
{{/block}}
{{block 'main'}}
<div class="box">