调整
This commit is contained in:
parent
fa8ed311c2
commit
4fa5e7e34d
@ -1,7 +1,11 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {useCpuUsage} from "src/utils/system";
|
import {useCpuUsage} from "src/utils/system";
|
||||||
import {computed} from "vue";
|
import {computed} from "vue";
|
||||||
|
const props = defineProps({
|
||||||
|
showLabel: {
|
||||||
|
default: true
|
||||||
|
}
|
||||||
|
})
|
||||||
const cpuUsage = useCpuUsage()
|
const cpuUsage = useCpuUsage()
|
||||||
const singleUsage = computed(()=>{
|
const singleUsage = computed(()=>{
|
||||||
return Number((cpuUsage.value[0] || 0).toFixed(2))
|
return Number((cpuUsage.value[0] || 0).toFixed(2))
|
||||||
@ -19,7 +23,12 @@ const colors = [
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<el-progress type="dashboard" :percentage="singleUsage" :color="colors" />
|
<el-progress type="dashboard" :percentage="singleUsage" :color="colors">
|
||||||
|
<template #default="{ percentage }">
|
||||||
|
<p class="percentage-value">{{ percentage }}%</p>
|
||||||
|
<p class="percentage-text" v-if="props.showLabel">CPU使用率</p>
|
||||||
|
</template>
|
||||||
|
</el-progress>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
@ -29,5 +38,10 @@ const colors = [
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.percentage-value {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
.percentage-text {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {useMemoryTotalSize, useMemoryUsage, useMemoryUsageSize} from "src/utils/system";
|
import {useMemoryTotalSize, useMemoryUsage, useMemoryUsageSize} from "src/utils/system";
|
||||||
|
const props = defineProps({
|
||||||
|
showLabel: {
|
||||||
|
default: true
|
||||||
|
}
|
||||||
|
})
|
||||||
const usage = useMemoryUsage()
|
const usage = useMemoryUsage()
|
||||||
const used = useMemoryUsageSize()
|
const used = useMemoryUsageSize()
|
||||||
const total = useMemoryTotalSize()
|
const total = useMemoryTotalSize()
|
||||||
@ -20,6 +24,7 @@ const colors = [
|
|||||||
<el-progress type="dashboard" :percentage="usage" :color="colors">
|
<el-progress type="dashboard" :percentage="usage" :color="colors">
|
||||||
<template #default="{ percentage }">
|
<template #default="{ percentage }">
|
||||||
<p class="percentage-value">{{ percentage }}%</p>
|
<p class="percentage-value">{{ percentage }}%</p>
|
||||||
|
<div class="percentage-text" v-if="props.showLabel">内存使用率</div>
|
||||||
</template>
|
</template>
|
||||||
</el-progress>
|
</el-progress>
|
||||||
</div>
|
</div>
|
||||||
@ -34,4 +39,7 @@ const colors = [
|
|||||||
.percentage-value {
|
.percentage-value {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
|
.percentage-text {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -79,6 +79,10 @@ export function bytesToSizeWithUnit(byteSize:number){
|
|||||||
return `${calcSize(byteSize,targetUnit)} ${targetUnit.unit}`
|
return `${calcSize(byteSize,targetUnit)} ${targetUnit.unit}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function numberToHz(number:number){
|
||||||
|
return bytesToSizeWithUnit(number).replace(FileUnit.B.unit,"")
|
||||||
|
}
|
||||||
|
|
||||||
export function calcSize(byteSize:number,targetUnit:FileUnitType){
|
export function calcSize(byteSize:number,targetUnit:FileUnitType){
|
||||||
return Number((byteSize / targetUnit.size).toFixed(2))
|
return Number((byteSize / targetUnit.size).toFixed(2))
|
||||||
}
|
}
|
@ -103,17 +103,12 @@ const table = reactive({
|
|||||||
|
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="4">
|
<el-col :span="4">
|
||||||
<CPUUsage>
|
<CPUUsage/>
|
||||||
<template #footer>
|
|
||||||
<div>CPU使用率</div>
|
|
||||||
</template>
|
|
||||||
</CPUUsage>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="4">
|
<el-col :span="4">
|
||||||
<MemoryUsage>
|
<MemoryUsage>
|
||||||
<template #footer="{used, total}">
|
<template #footer="{used, total}">
|
||||||
<div>内存</div>
|
<div class="text-sm">{{used}}/{{total}}</div>
|
||||||
<div>{{used}}/{{total}}</div>
|
|
||||||
</template>
|
</template>
|
||||||
</MemoryUsage>
|
</MemoryUsage>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
Loading…
Reference in New Issue
Block a user