Skip to content

Commit 02f0f6d

Browse files
committed
localise filesize
1 parent e676cb4 commit 02f0f6d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/components/FileItem.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ watchEffect(() => {
1919
});
2020
2121
const fileData = computed(() => URL.createObjectURL(props.fileObj.file));
22+
23+
const computeFileSize = (size: number) =>
24+
(size / (1024 * 1024)).toLocaleString(undefined, { minimumFractionDigits: 1, maximumFractionDigits: 1 }); // NoSonar this is to convert byte to MB
2225
</script>
2326

2427
<template>
@@ -37,9 +40,9 @@ const fileData = computed(() => URL.createObjectURL(props.fileObj.file));
3740
</a>
3841
<div>
3942
<div><span class="field-title">Name:</span> {{ fileObj.file.name }}</div>
40-
<div><span class="field-title">Original Size:</span> {{ (orgSize / (1024 * 1024)).toFixed(1) }}MB</div>
43+
<div><span class="field-title">Original Size:</span> {{ computeFileSize(orgSize) }}MB</div>
4144
<div v-if="compSize">
42-
<span class="field-title">Compressed Size:</span> {{ (compSize / (1024 * 1024)).toFixed(1) }}MB
45+
<span class="field-title">Compressed Size:</span> {{ computeFileSize(compSize) }}MB
4346
</div>
4447
</div>
4548
<a

0 commit comments

Comments
 (0)