Skip to content

Commit

Permalink
#铃推送fix: 优化储存查看
Browse files Browse the repository at this point in the history
  • Loading branch information
yusheng929 committed Aug 28, 2024
1 parent ac57a79 commit b026042
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const State = karin.command(/^#系统信息$/, async (e) => {
const RAMB = await RAM.SwapRAMUsage()
const adapter = e.bot.adapter.name
const implementation = e.bot.version.app_name || e.bot.version.name
const disk = await Disk.Disk()
const disk = Disk.Disk()
const system = System.System()

// 组装消息
Expand Down
6 changes: 3 additions & 3 deletions state/Disk.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import os from 'os'
import { execSync } from 'child_process'

const Disk = async () => {
const Disk = () => {
try {
let output = ''
const platform = os.platform()

if (platform === 'win32') {
// Windows 系统使用 wmic 命令
output = await execSync('wmic logicaldisk get size,freespace,caption').toString()
output = execSync('wmic logicaldisk get size,freespace,caption').toString()
const lines = output.trim().split('\n')

const diskInfo = []
Expand All @@ -28,7 +28,7 @@ const Disk = async () => {
return diskInfo.length > 0 ? diskInfo.join('\n') : '无法获取磁盘信息'
} else if (platform === 'linux' || platform === 'darwin') {
// Linux 和 macOS 系统使用 df 命令
output = await execSync('df -h /').toString()
output = execSync('df -h /').toString()
const lines = output.trim().split('\n')
const data = lines[1].split(/\s+/)
const totalSize = data[1]
Expand Down

0 comments on commit b026042

Please sign in to comment.