Skip to content

Commit

Permalink
fix: bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yusheng929 committed Feb 2, 2025
1 parent ea662fc commit b31e37d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
10 changes: 7 additions & 3 deletions src/apps/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ export const state = karin.command(/^#系统信息(pro)?$/, async (e) => {
'CPU信息',
`CPU: ${CPUInfo}`,
`CPU使用率: ${CPUUsage}%`,
`CPU温度: ${CPUTemp}`,
`CPU缓存: ${CPUCache}`
`CPU温度: ${CPUTemp}°C`,
'CPU缓存:',
`L1数据缓存: ${CPUCache.l1d}`,
`L1指令缓存: ${CPUCache.l1i}`,
`L2缓存: ${CPUCache.l2}`,
`L3缓存: ${CPUCache.l3}`
].join('\n'))

list.push([
Expand All @@ -72,7 +76,7 @@ export const state = karin.command(/^#系统信息(pro)?$/, async (e) => {

list.push([
'磁盘信息:',
`${DiskInfos}`,
`${DiskInfos}`
].join('\n'))

const msg = list.map((v) => segment.text(v))
Expand Down
15 changes: 8 additions & 7 deletions src/models/state/CPU.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Size } from '@/components/Size'
import si from 'systeminformation'

/**
Expand Down Expand Up @@ -35,11 +36,11 @@ const getCPUInfo = async (): Promise<string> => {
* 获取CPU温度
* @returns {Promise<number>}
*/
const getCPUTemp = async (): Promise<string | number> => {
const getCPUTemp = async (): Promise<number> => {
try {
const cpuTemp = await si.cpuTemperature()

const data = `${cpuTemp.main}°C`
const data = cpuTemp.main
return data
} catch (error) {
return 0
Expand All @@ -60,13 +61,13 @@ const getCPUCache = async (): Promise<any> => {
l3: ''
}
const cpuCache = await si.cpuCache()
data.l1d = cpuCache.l1d > 1024 ? `${(cpuCache.l1d / 1024).toFixed(2)}MB` : `${cpuCache.l1d}KB`
data.l1i = cpuCache.l1i > 1024 ? `${(cpuCache.l1i / 1024).toFixed(2)}MB` : `${cpuCache.l1i}KB`
data.l2 = cpuCache.l2 > 1024 ? `${(cpuCache.l2 / 1024).toFixed(2)}MB` : `${cpuCache.l2}KB`
data.l3 = cpuCache.l3 > 1024 ? `${(cpuCache.l3 / 1024).toFixed(2)}MB` : `${cpuCache.l3}KB`
data.l1d = await Size(cpuCache.l1d)
data.l1i = await Size(cpuCache.l1i)
data.l2 = await Size(cpuCache.l2)
data.l3 = await Size(cpuCache.l3)
return data
} catch (error) {
return '少女不知道哦'
return ''
}
}

Expand Down

0 comments on commit b31e37d

Please sign in to comment.