UNPKG

yunzai-micro-plugin

Version:

Yunzai开发管理面板

25 lines (22 loc) 681 B
import { si } from "./utils.js" /** 获取CPU占用 */ export default async function getCpuInfo() { let { currentLoad: { currentLoad }, cpu, fullLoad } = await si.get({ currentLoad: "currentLoad", cpu: "manufacturer,speed,cores", fullLoad: "*" }) let { manufacturer, speed, cores } = cpu if (currentLoad == null || currentLoad == undefined) return false fullLoad = Math.round(fullLoad) manufacturer = manufacturer?.split(" ")?.[0] ?? "unknown" return { inner: Math.round(currentLoad) / 100, title: "CPU", info: [ `${manufacturer}`, `${cores}${speed}GHz`, `CPU满载率 ${fullLoad}%` ] } }