diff --git a/frontend/src/components/files/ListingItem.vue b/frontend/src/components/files/ListingItem.vue index 303eeaf4..6beb014d 100644 --- a/frontend/src/components/files/ListingItem.vue +++ b/frontend/src/components/files/ListingItem.vue @@ -41,7 +41,7 @@ import { useFileStore } from "@/stores/file"; import { useLayoutStore } from "@/stores/layout"; import { enableThumbs } from "@/utils/constants"; -import { filesize } from "filesize"; +import { filesize } from "@/utils"; import dayjs from "dayjs"; import { files as api } from "@/api"; import * as upload from "@/utils/upload"; @@ -105,9 +105,7 @@ export default { ...mapActions(useFileStore, ["removeSelected"]), ...mapActions(useLayoutStore, ["showHover", "closeHovers"]), humanSize: function () { - return this.type == "invalid_link" - ? "invalid link" - : filesize(this.size, { base: 2 }); + return this.type == "invalid_link" ? "invalid link" : filesize(this.size); }, humanTime: function () { if (this.readOnly == undefined && this.user.dateFormat) { diff --git a/frontend/src/components/prompts/Info.vue b/frontend/src/components/prompts/Info.vue index 09df13cd..a07292aa 100644 --- a/frontend/src/components/prompts/Info.vue +++ b/frontend/src/components/prompts/Info.vue @@ -83,7 +83,7 @@ import { mapActions, mapState } from "pinia"; import { useFileStore } from "@/stores/file"; import { useLayoutStore } from "@/stores/layout"; -import { filesize } from "filesize"; +import { filesize } from "@/utils"; import dayjs from "dayjs"; import { files as api } from "@/api"; @@ -99,7 +99,7 @@ export default { ]), humanSize: function () { if (this.selectedCount === 0 || !this.isListing) { - return filesize(this.req.size, { base: 2 }); + return filesize(this.req.size); } let sum = 0; @@ -108,7 +108,7 @@ export default { sum += this.req.items[selected].size; } - return filesize(sum, { base: 2 }); + return filesize(sum); }, humanTime: function () { if (this.selectedCount === 0) { diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index 5646c03d..d7f0bd9b 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -1 +1,6 @@ -// export * from "./funcs"; +import { partial } from "filesize"; + +/** + * Formats filesize as KiB/MiB/... + */ +export const filesize = partial({ base: 2 }); diff --git a/frontend/src/views/Share.vue b/frontend/src/views/Share.vue index cff13f9a..288f26f2 100644 --- a/frontend/src/views/Share.vue +++ b/frontend/src/views/Share.vue @@ -181,7 +181,7 @@