From 96f6b77b0f8975f67c505facbadf314a02179cb7 Mon Sep 17 00:00:00 2001 From: Jamie Banks Date: Tue, 9 Jun 2026 09:41:05 +0100 Subject: [PATCH] feat: :sparkles: add sorting functionality for files and folders in AccountTab --- frontend/src/components/AccountTab.vue | 63 +++++++++++++++++++++----- 1 file changed, 52 insertions(+), 11 deletions(-) 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

  • -
    - - - {{ f.name }} +
    + + + {{ f.name }}
    - {{ fmtSize(f.size) }} + {{ fmtSize(f.size) }} + {{ fmtDate(f.last_modified) }}
  • -
  • No files
  • +
  • No files
-- 2.47.3