Skip to content

Commit

Permalink
feat: 流量单位显示由 EB 提升到 YB
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Mar 24, 2024
1 parent ce75718 commit 67b678f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store-front-end",
"version": "2.14.212",
"version": "2.14.213",
"private": true,
"scripts": {
"dev": "vite --host",
Expand Down
7 changes: 3 additions & 4 deletions src/utils/flowTransfer.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
type Unit = 'B' | 'KB' | 'MB' | 'GB' | 'TB' | 'PB' | 'EB';
type Unit = 'B' | 'KB' | 'MB' | 'GB' | 'TB' | 'PB' | 'EB' | 'ZB' | 'YB';

const flowTransfer = (flow: number, unit: Unit) => {
const unitList: Unit[] = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'];
const unitList: Unit[] = ['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]);
};
Expand Down

0 comments on commit 67b678f

Please sign in to comment.