diff --git a/frontend/src/components/AccountTab.vue b/frontend/src/components/AccountTab.vue index 62f129d..52b9a29 100644 --- a/frontend/src/components/AccountTab.vue +++ b/frontend/src/components/AccountTab.vue @@ -34,6 +34,38 @@ const renameTarget = ref<{ key: string; } | null>(null); const renameValue = ref(""); +const sortBy = ref("name-asc"); + +const sortedFolders = computed(() => { + const arr = [...folders.value]; + if (sortBy.value === "name-asc") { + arr.sort((a, b) => a.name.localeCompare(b.name)); + } else if (sortBy.value === "name-desc") { + arr.sort((a, b) => b.name.localeCompare(a.name)); + } + return arr; +}); + +const sortedFiles = computed(() => { + const arr = [...files.value]; + const [field, dir] = sortBy.value.split("-"); + + arr.sort((a, b) => { + let cmp = 0; + if (field === "name") { + cmp = a.name.localeCompare(b.name); + } else if (field === "date") { + const ta = a.last_modified ? new Date(a.last_modified).getTime() : 0; + const tb = b.last_modified ? new Date(b.last_modified).getTime() : 0; + cmp = ta - tb; + } else if (field === "size") { + cmp = a.size - b.size; + } + return dir === "asc" ? cmp : -cmp; + }); + + return arr; +}); let searchTimer: number | undefined; @@ -300,8 +332,8 @@ watch( -
-
+
+
+ @@ -324,7 +364,7 @@ watch(

Folders

  • @@ -349,7 +389,7 @@ watch(
  • -
  • No folders
  • +
  • No folders
@@ -357,17 +397,18 @@ watch(

Files