mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-05 17:42:49 +08:00
优化bytes助手函数
This commit is contained in:
@@ -1142,15 +1142,8 @@ define(["jquery", "tableSelect", "ckeditor", 'miniTheme', 'tableData', 'citypick
|
|||||||
},
|
},
|
||||||
bytes: (data) => {
|
bytes: (data) => {
|
||||||
var size = admin.table.returnColumnValue(data);
|
var size = admin.table.returnColumnValue(data);
|
||||||
if (size > 0) {
|
sizeReadable = admin.bytes(size)
|
||||||
const kb = 1024
|
return sizeReadable
|
||||||
const unit = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
|
||||||
const i = Math.floor(Math.log(size) / Math.log(kb))
|
|
||||||
const num = (size / Math.pow(kb, i)).toPrecision(3)
|
|
||||||
const u = unit[i]
|
|
||||||
return num + u;
|
|
||||||
}
|
|
||||||
return '0B'
|
|
||||||
},
|
},
|
||||||
copyText(data) {
|
copyText(data) {
|
||||||
var option = data.LAY_COL;
|
var option = data.LAY_COL;
|
||||||
@@ -2314,6 +2307,18 @@ define(["jquery", "tableSelect", "ckeditor", 'miniTheme', 'tableData', 'citypick
|
|||||||
return !1
|
return !1
|
||||||
},
|
},
|
||||||
|
|
||||||
|
bytes(size) {
|
||||||
|
if (size > 0) {
|
||||||
|
const kb = 1024
|
||||||
|
const unit = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
||||||
|
const i = Math.floor(Math.log(size) / Math.log(kb))
|
||||||
|
const num = (size / Math.pow(kb, i)).toPrecision(3)
|
||||||
|
const u = unit[i]
|
||||||
|
return num + u;
|
||||||
|
}
|
||||||
|
return '0B';
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
return admin;
|
return admin;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user