diff --git a/frontend/admin/src/pages/PostCreatePage.vue b/frontend/admin/src/pages/PostCreatePage.vue index 623c3fd..587c45c 100644 --- a/frontend/admin/src/pages/PostCreatePage.vue +++ b/frontend/admin/src/pages/PostCreatePage.vue @@ -189,17 +189,15 @@ const getFileIcon = (file) => { // Format file size helper const formatFileSize = (bytes) => { - if (bytes === 0) return '0 B'; - const k = BigInt(1024); + if (!bytes && bytes !== 0) return '0 B'; const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; - const bytesValue = BigInt(bytes); - let i = 0; - let size = bytesValue; - while (size >= k && i < sizes.length - 1) { - size = size / k; - i++; - } - return `${Number(size).toLocaleString('en-US')} ${sizes[i]}`; + const base = 1024; + let size = Number(bytes); + if (isNaN(size)) return '0 B'; + + const i = Math.floor(Math.log(size) / Math.log(base)); + size = size / Math.pow(base, i); + return `${size.toFixed(2)} ${sizes[i]}`; }; @@ -271,16 +269,17 @@ const formatFileSize = (bytes) => { class="relative border border-gray-200 rounded-md p-2 flex items-center">
+ :alt="media.file_name">
-
{{ media.fileName }} +
+ {{ media.name }}
-