From 07c2ff4c1549d889f6a211c0c5ff4fff8de78acd Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Sat, 18 Nov 2023 06:31:26 -0800 Subject: [PATCH] Keyboard sort by 1-2-3 supplemented by the key left of them for default sort. --- frontend/src/App.vue | 5 +++-- frontend/src/stores/main.ts | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 47d57cb..c34510e 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -21,6 +21,7 @@ import { useMainStore } from '@/stores/main' import { computed } from 'vue' import Router from '@/router/index' +import type { SortOrder } from './utils/docsort' interface Path { path: string @@ -102,9 +103,9 @@ const globalShortcutHandler = (event: KeyboardEvent) => { else if ( !input && keyup && - (event.key === '1' || event.key === '2' || event.key === '3') + (event.code === 'Backquote' || event.key === '1' || event.key === '2' || event.key === '3') ) { - fileExplorer.toggleSortColumn(+event.key) + store.sort(['', 'name', 'modified', 'size'][+event.key || 0] as SortOrder) } // Rename else if (c && keyup && !event.ctrlKey && (event.key === 'F2' || event.key === 'r')) { diff --git a/frontend/src/stores/main.ts b/frontend/src/stores/main.ts index 2fa29d6..5dcc671 100644 --- a/frontend/src/stores/main.ts +++ b/frontend/src/stores/main.ts @@ -79,6 +79,10 @@ export const useMainStore = defineStore({ if (this.query) this.prefs.sortFiltered = this.prefs.sortFiltered === name ? '' : name else this.prefs.sortListing = this.prefs.sortListing === name ? '' : name }, + sort(name: SortOrder | '') { + if (this.query) this.prefs.sortFiltered = name + else this.prefs.sortListing = name + }, }, getters: { sortOrder(): SortOrder { return this.query ? this.prefs.sortFiltered : this.prefs.sortListing },