0
0
Fork 0

Merge pull request '#7889 - Implmenet main shortcuts' (!655) from 7889_main_shortcuts into dev

Reviewed-on: verdnatura/salix-front#655
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
Javier Segarra 2024-09-02 13:03:19 +00:00
commit d65b52804d
3 changed files with 26 additions and 0 deletions

View File

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

View File

@ -1,6 +1,8 @@
import { boot } from 'quasar/wrappers';
import qFormMixin from './qformMixin';
import mainShortcutMixin from './mainShortcutMixin';
export default boot(({ app }) => {
app.mixin(qFormMixin);
app.mixin(mainShortcutMixin);
});

View File

@ -7,6 +7,7 @@ export default {
title: 'routes',
icon: 'vn:delivery',
moduleName: 'Route',
keyBinding: 'r',
},
component: RouterView,
redirect: { name: 'RouteMain' },