fix: search file name by repo_id

This commit is contained in:
jialin
2024-06-15 20:41:26 +08:00
parent b416a14554
commit 2352c316c0
6 changed files with 98 additions and 14 deletions
+17
View File
@@ -11,3 +11,20 @@ export const handleBatchRequest = async (
) => {
return Promise.all(list.map((item) => fn(item)));
};
export const convertFileSize = (sizeInBytes: number) => {
if (!sizeInBytes) {
return '0 B';
}
if (sizeInBytes < 1024) {
return `${sizeInBytes.toFixed(2)} B`;
} else if (sizeInBytes < 1024 * 1024) {
return `${(sizeInBytes / 1024).toFixed(2)} KB`;
} else if (sizeInBytes < 1024 * 1024 * 1024) {
return `${(sizeInBytes / (1024 * 1024)).toFixed(2)} MB`;
} else if (sizeInBytes < 1024 * 1024 * 1024 * 1024) {
return `${(sizeInBytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
} else {
return `${(sizeInBytes / (1024 * 1024 * 1024 * 1024)).toFixed(2)} TB`;
}
};