feat: 流量单位显示由 EB 提升到 YB

This commit is contained in:
xream
2024-03-25 03:50:47 +08:00
parent 50b19026c9
commit 054ea43c28
2 changed files with 3 additions and 3 deletions

View File

@@ -138,10 +138,10 @@ export function parseFlowHeaders(flowHeaders) {
return { expires, total, usage: { upload, download } };
}
export function flowTransfer(flow, unit = 'B') {
const unitList = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'];
const unitList = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
let unitIndex = unitList.indexOf(unit);
return flow < 1024
return flow < 1024 || unitIndex === unitList.length - 1
? { value: flow.toFixed(1), unit: unit }
: flowTransfer(flow / 1024, unitList[++unitIndex]);
}