fix: keyboard-shortcuts typing

This commit is contained in:
Dominik Pschenitschni 2022-01-30 14:05:26 +01:00
parent 187e62a7ec
commit 57965b1ea3
Signed by: dpschen
GPG Key ID: B257AC0149F43A77
2 changed files with 19 additions and 4 deletions

View File

@ -19,7 +19,7 @@
class="shortcut-keys" class="shortcut-keys"
is="dd" is="dd"
:keys="sc.keys" :keys="sc.keys"
:combination="typeof sc.combination !== 'undefined' ? $t(`keyboardShortcuts.${sc.combination}`) : null" :combination="sc.combination && $t(`keyboardShortcuts.${sc.combination}`)"
/> />
</template> </template>
</dl> </dl>
@ -29,7 +29,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import {store} from '@/store' import {useStore} from 'vuex'
import Shortcut from '@/components/misc/shortcut.vue' import Shortcut from '@/components/misc/shortcut.vue'
import Message from '@/components/misc/message.vue' import Message from '@/components/misc/message.vue'
@ -37,6 +37,7 @@ import Message from '@/components/misc/message.vue'
import {KEYBOARD_SHORTCUTS_ACTIVE} from '@/store/mutation-types' import {KEYBOARD_SHORTCUTS_ACTIVE} from '@/store/mutation-types'
import {KEYBOARD_SHORTCUTS as shortcuts} from './shortcuts' import {KEYBOARD_SHORTCUTS as shortcuts} from './shortcuts'
const store = useStore()
function close() { function close() {
store.commit(KEYBOARD_SHORTCUTS_ACTIVE, false) store.commit(KEYBOARD_SHORTCUTS_ACTIVE, false)
} }

View File

@ -1,8 +1,22 @@
import {RouteLocation} from 'vue-router'
import {isAppleDevice} from '@/helpers/isAppleDevice' import {isAppleDevice} from '@/helpers/isAppleDevice'
const ctrl = isAppleDevice() ? '⌘' : 'ctrl' const ctrl = isAppleDevice() ? '⌘' : 'ctrl'
export const KEYBOARD_SHORTCUTS = [ interface Shortcut {
title: string
keys: string[]
combination?: 'then'
}
interface ShortcutGroup {
title: string
available?: (route: RouteLocation) => boolean
shortcuts: Shortcut[]
}
export const KEYBOARD_SHORTCUTS : ShortcutGroup[] = [
{ {
title: 'keyboardShortcuts.general', title: 'keyboardShortcuts.general',
shortcuts: [ shortcuts: [
@ -28,7 +42,7 @@ export const KEYBOARD_SHORTCUTS = [
}, },
{ {
title: 'keyboardShortcuts.list.title', title: 'keyboardShortcuts.list.title',
available: (route) => route.name.startsWith('list.'), available: (route) => (route.name as string)?.startsWith('list.'),
shortcuts: [ shortcuts: [
{ {
title: 'keyboardShortcuts.list.switchToListView', title: 'keyboardShortcuts.list.switchToListView',