diff --git a/src/boot/mainShortcutMixin.js b/src/boot/mainShortcutMixin.js new file mode 100644 index 000000000..c4d37fd73 --- /dev/null +++ b/src/boot/mainShortcutMixin.js @@ -0,0 +1,23 @@ +import routes from 'src/router/modules'; + +import { useRouter } from 'vue-router'; +export default { + mounted: function () { + const router = useRouter(); + const keyBindingMap = routes + .filter((route) => route.meta.keyBinding) + .reduce((map, route) => { + map[route.meta.keyBinding.toLowerCase()] = route.path; + return map; + }, {}); + const handleKeyDown = (event) => { + const { ctrlKey, altKey, key } = event; + event.preventDefault(); + if (ctrlKey && altKey && keyBindingMap[key]) { + router.push(keyBindingMap[key]); + } + }; + + window.addEventListener('keydown', handleKeyDown); + }, +}; diff --git a/src/boot/quasar.js b/src/boot/quasar.js index 00dd2cd5e..e2035c880 100644 --- a/src/boot/quasar.js +++ b/src/boot/quasar.js @@ -1,8 +1,10 @@ import { boot } from 'quasar/wrappers'; import qFormMixin from './qformMixin'; +import mainShortcutMixin from './mainShortcutMixin'; import keyShortcut from './keyShortcut'; export default boot(({ app }) => { app.mixin(qFormMixin); + app.mixin(mainShortcutMixin); app.directive('shortcut', keyShortcut); }); diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index 077522e6d..06d54efb2 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -333,299 +333,280 @@ defineExpose({ -