feat: 资源监控信息
This commit is contained in:
@@ -72,3 +72,18 @@ export function diffValue(
|
||||
if (Number.isNaN(value)) return 0;
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式时间不带年份
|
||||
*
|
||||
* 年-月\n时:分 列如:10-13 \n 15:13
|
||||
* @returns MM-DD\nHH:mm
|
||||
*/
|
||||
export function parseDateWithoutYear(date: string | number | Date) {
|
||||
const day = dayjs(date);
|
||||
const M: string = `${day.month() + 1}`.padStart(2, '0');
|
||||
const D: string = `${day.date()}`.padStart(2, '0');
|
||||
const H: string = `${day.hour()}`.padStart(2, '0');
|
||||
const m: string = `${day.minute()}`.padStart(2, '0');
|
||||
return `${M}-${D}\n${H}:${m}`;
|
||||
}
|
||||
|
||||
@@ -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