效果图:
我的磁盘情况:
程序执行结果:
nodejs实现:
const d = require('diskinfo'); // 需安装diskinfo依赖
d.getDrives(function (err: any, aDrives: any) {
for (var i = 0; i < aDrives.length; i++) {
console.log('磁盘:' + aDrives[i].mounted);
console.log('磁盘总内存:' + aDrives[i].blocks);
console.log('磁盘已用内存:' + aDrives[i].used);
console.log('磁盘可用内存:' + aDrives[i].available);
console.log('磁盘已用内存百分比: ' + aDrives[i].capacity);
console.log('-----------------------------------------');
}
})
但该方法获取不到每个磁盘的名称,若想获取每个磁盘的名称,点击直通车:
https://blog.csdn.net/qq_41176306/article/details/122699640