Simplify filesize calls
This commit is contained in:
parent
28a724e793
commit
2df99e0d8c
@ -41,7 +41,7 @@ import { useFileStore } from "@/stores/file";
|
|||||||
import { useLayoutStore } from "@/stores/layout";
|
import { useLayoutStore } from "@/stores/layout";
|
||||||
|
|
||||||
import { enableThumbs } from "@/utils/constants";
|
import { enableThumbs } from "@/utils/constants";
|
||||||
import { filesize } from "filesize";
|
import { filesize } from "@/utils";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { files as api } from "@/api";
|
import { files as api } from "@/api";
|
||||||
import * as upload from "@/utils/upload";
|
import * as upload from "@/utils/upload";
|
||||||
@ -105,9 +105,7 @@ export default {
|
|||||||
...mapActions(useFileStore, ["removeSelected"]),
|
...mapActions(useFileStore, ["removeSelected"]),
|
||||||
...mapActions(useLayoutStore, ["showHover", "closeHovers"]),
|
...mapActions(useLayoutStore, ["showHover", "closeHovers"]),
|
||||||
humanSize: function () {
|
humanSize: function () {
|
||||||
return this.type == "invalid_link"
|
return this.type == "invalid_link" ? "invalid link" : filesize(this.size);
|
||||||
? "invalid link"
|
|
||||||
: filesize(this.size, { base: 2 });
|
|
||||||
},
|
},
|
||||||
humanTime: function () {
|
humanTime: function () {
|
||||||
if (this.readOnly == undefined && this.user.dateFormat) {
|
if (this.readOnly == undefined && this.user.dateFormat) {
|
||||||
|
|||||||
@ -83,7 +83,7 @@
|
|||||||
import { mapActions, mapState } from "pinia";
|
import { mapActions, mapState } from "pinia";
|
||||||
import { useFileStore } from "@/stores/file";
|
import { useFileStore } from "@/stores/file";
|
||||||
import { useLayoutStore } from "@/stores/layout";
|
import { useLayoutStore } from "@/stores/layout";
|
||||||
import { filesize } from "filesize";
|
import { filesize } from "@/utils";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { files as api } from "@/api";
|
import { files as api } from "@/api";
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ export default {
|
|||||||
]),
|
]),
|
||||||
humanSize: function () {
|
humanSize: function () {
|
||||||
if (this.selectedCount === 0 || !this.isListing) {
|
if (this.selectedCount === 0 || !this.isListing) {
|
||||||
return filesize(this.req.size, { base: 2 });
|
return filesize(this.req.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
let sum = 0;
|
let sum = 0;
|
||||||
@ -108,7 +108,7 @@ export default {
|
|||||||
sum += this.req.items[selected].size;
|
sum += this.req.items[selected].size;
|
||||||
}
|
}
|
||||||
|
|
||||||
return filesize(sum, { base: 2 });
|
return filesize(sum);
|
||||||
},
|
},
|
||||||
humanTime: function () {
|
humanTime: function () {
|
||||||
if (this.selectedCount === 0) {
|
if (this.selectedCount === 0) {
|
||||||
|
|||||||
@ -1 +1,6 @@
|
|||||||
// export * from "./funcs";
|
import { partial } from "filesize";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats filesize as KiB/MiB/...
|
||||||
|
*/
|
||||||
|
export const filesize = partial({ base: 2 });
|
||||||
|
|||||||
@ -181,7 +181,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { pub as api } from "@/api";
|
import { pub as api } from "@/api";
|
||||||
import { filesize } from "filesize";
|
import { filesize } from "@/utils";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { Base64 } from "js-base64";
|
import { Base64 } from "js-base64";
|
||||||
|
|
||||||
@ -241,7 +241,7 @@ const humanSize = computed(() => {
|
|||||||
if (req.value) {
|
if (req.value) {
|
||||||
return req.value.isDir
|
return req.value.isDir
|
||||||
? req.value.items.length
|
? req.value.items.length
|
||||||
: filesize(req.value.size ?? 0, { base: 2 });
|
: filesize(req.value.size ?? 0);
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user