mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-20 16:20:25 +08:00
feat: 新增数据库表信息查看及其他优化
This commit is contained in:
21
mayfly_go_web/src/common/utils/format.ts
Normal file
21
mayfly_go_web/src/common/utils/format.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* 格式化字节单位
|
||||
* @param size byte size
|
||||
* @returns
|
||||
*/
|
||||
export function formatByteSize(size: any) {
|
||||
const value = Number(size);
|
||||
if (size && !isNaN(value)) {
|
||||
const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB', 'BB'];
|
||||
let index = 0;
|
||||
let k = value;
|
||||
if (value >= 1024) {
|
||||
while (k > 1024) {
|
||||
k = k / 1024;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
return `${k.toFixed(2)}${units[index]}`;
|
||||
}
|
||||
return '-';
|
||||
}
|
||||
Reference in New Issue
Block a user