优化显示
Some checks are pending
TDevOPsCICD / build-image (push) Waiting to run

This commit is contained in:
cheney 2026-01-27 16:59:57 +08:00
parent 6ddcff5275
commit 24961dc734

View File

@ -121,11 +121,13 @@ kitcommand.regTo( parser )
// }); // });
parser.addCmdLine("platform", "平台信息", function (cli) { parser.addCmdLine("platform [-json]", "平台信息", function (cli) {
// 调用主函数并打印结果
// 调用主函数并打印结果
getAllDeviceInfo().then(info => { getAllDeviceInfo().then(info => {
console.log('Device Information:'); console.log('Device Information:');
var table = [] let table = []
for ( let k in info.os ){ for ( let k in info.os ){
table.push({ '项' : 'OS ' + k, '值' : info.os[k]}) table.push({ '项' : 'OS ' + k, '值' : info.os[k]})
} }
@ -139,18 +141,24 @@ parser.addCmdLine("platform", "平台信息", function (cli) {
table.push({ '项' : 'Mem ' + k, '值' : info.memory[k]}) table.push({ '项' : 'Mem ' + k, '值' : info.memory[k]})
} }
console.table(table); if( cli.hasFlag("json") ) {
const disks = info.disk; console.log( JSON.stringify(info, null, 4));
disks.forEach(disk => { } else {
console.log(`磁盘 ${disk.mount}:`); console.table(table);
console.log(` 总空间: ${(disk.size / 1024 / 1024 / 1024).toFixed(2)} GB`); const disks = info.disk;
console.log(` 已用空间: ${(disk.used / 1024 / 1024 / 1024).toFixed(2)} GB`);
console.log(` 可用空间: ${(disk.available / 1024 / 1024 / 1024).toFixed(2)} GB`);
console.log(` 使用率: ${disk.use}%`);
});
console.log( JSON.stringify(info, null, 4));
const diskTable = []
disks.forEach(disk => {
diskTable.push({
'盘符' : disk.mount
,'总空间' : `${(disk.size / 1024 / 1024 / 1024).toFixed(2)} GB`
,'已用空间' : `${(disk.used / 1024 / 1024 / 1024).toFixed(2)} GB`
,'可用空间' : `${(disk.available / 1024 / 1024 / 1024).toFixed(2)} GB`
,'使用率' : `${disk.use}%`
})
});
console.table(diskTable);
}
}).catch(error => { }).catch(error => {
console.error('Error getting device information:', error); console.error('Error getting device information:', error);
}); });