Browse Source

fea: 增加子节处理函数

vera_min 1 năm trước cách đây
mục cha
commit
253aa6e8e9
1 tập tin đã thay đổi với 10 bổ sung0 xóa
  1. 10 0
      src/utils/common.ts

+ 10 - 0
src/utils/common.ts

@@ -59,3 +59,13 @@ export function selectDictLabel(data: any[], value: string): string {
     })
     })
     return actions.join('');
     return actions.join('');
 }
 }
+
+export function formatSize(kb:number) {
+    if (kb <= 0) {
+        return "0 B";
+    }
+
+    const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
+    const i = Math.floor(Math.log(kb) / Math.log(1024));
+    return (kb / Math.pow(1024, i)).toFixed(2) + " " + units[i];
+}