feat: apply mixin
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
ae70256b5e
commit
d8e3f9dfd9
|
@ -0,0 +1,29 @@
|
|||
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();
|
||||
|
||||
const combination = `${ctrlKey ? 'Ctrl+' : ''}${
|
||||
altKey ? 'Alt+' : ''
|
||||
}${key.toLowerCase()}`;
|
||||
console.log(ctrlKey, altKey, key, combination);
|
||||
|
||||
if (ctrlKey && altKey && keyBindingMap[key]) {
|
||||
router.push(keyBindingMap[key]);
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('keydown', handleKeyDown);
|
||||
},
|
||||
};
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -5,8 +5,9 @@ export default {
|
|||
name: 'Route',
|
||||
meta: {
|
||||
title: 'routes',
|
||||
icon: 'vn:delivery',
|
||||
icon: 'vn:delivesry',
|
||||
moduleName: 'Route',
|
||||
keyBinding: 'r',
|
||||
},
|
||||
component: RouterView,
|
||||
redirect: { name: 'RouteMain' },
|
||||
|
|
Loading…
Reference in New Issue