feat: 资源监控信息
This commit is contained in:
1 parent
a824e64063
commit
dcbd75b8c9
4 files changed
+644
No files matched your search
@@ -91,3 +91,30 @@ export function parseObjLineToHump(obj: any): any {
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换磁盘容量
|
||||
* @param size 数值大小
|
||||
* @returns
|
||||
*/
|
||||
export function parseSizeFromMB(size: number): string {
|
||||
const num = 1024.0;
|
||||
if (size < num) return size + ' MB';
|
||||
if (size < Math.pow(num, 2)) return (size / num).toFixed(2) + ' GB';
|
||||
return (size / Math.pow(num, 3)).toFixed(2) + ' TB';
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换网络速率
|
||||
* @param size 数值大小
|
||||
* @returns
|
||||
*/
|
||||
export function parseSizeFromKBs(size: number): string {
|
||||
const num = 1024.0;
|
||||
if (size < num) return size + ' KB/s';
|
||||
if (size < Math.pow(num, 2)) return (size / num).toFixed(2) + ' MB/s';
|
||||
if (size < Math.pow(num, 3)) {
|
||||
return (size / Math.pow(num, 2)).toFixed(2) + ' GB/s';
|
||||
}
|
||||
return (size / Math.pow(num, 3)).toFixed(2) + ' TB/s';
|
||||
}
|
||||
Reference in new issue
Block a user