Keyboard sort by 1-2-3 supplemented by the key left of them for default sort.

This commit is contained in:
Leo Vasanko 2023-11-18 06:31:26 -08:00
parent e20b04189f
commit 07c2ff4c15
2 changed files with 7 additions and 2 deletions

View File

@ -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')) {

View File

@ -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 },