forked from verdnatura/salix-front
fix(shortcutMixin): refs #8010 not mixin
This commit is contained in:
parent
5d4b5ad598
commit
5411a667eb
|
@ -1,38 +0,0 @@
|
||||||
import routes from 'src/router/modules';
|
|
||||||
import { useRouter } from 'vue-router';
|
|
||||||
|
|
||||||
let isNotified = false;
|
|
||||||
|
|
||||||
export default {
|
|
||||||
created: function () {
|
|
||||||
const router = useRouter();
|
|
||||||
const keyBindingMap = routes
|
|
||||||
.filter((route) => route.meta.keyBinding)
|
|
||||||
.reduce((map, route) => {
|
|
||||||
map['Key' + route.meta.keyBinding.toUpperCase()] = route.path;
|
|
||||||
return map;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
const handleKeyDown = (event) => {
|
|
||||||
const { ctrlKey, altKey, code } = event;
|
|
||||||
|
|
||||||
if (ctrlKey && altKey && keyBindingMap[code] && !isNotified) {
|
|
||||||
event.preventDefault();
|
|
||||||
router.push(keyBindingMap[code]);
|
|
||||||
isNotified = true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleKeyUp = (event) => {
|
|
||||||
const { ctrlKey, altKey } = event;
|
|
||||||
|
|
||||||
// Resetea la bandera cuando se sueltan las teclas ctrl o alt
|
|
||||||
if (!ctrlKey || !altKey) {
|
|
||||||
isNotified = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
window.addEventListener('keydown', handleKeyDown);
|
|
||||||
window.addEventListener('keyup', handleKeyUp);
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -1,13 +1,11 @@
|
||||||
import { boot } from 'quasar/wrappers';
|
import { boot } from 'quasar/wrappers';
|
||||||
import qFormMixin from './qformMixin';
|
import qFormMixin from './qformMixin';
|
||||||
import mainShortcutMixin from './mainShortcutMixin';
|
|
||||||
import keyShortcut from './keyShortcut';
|
import keyShortcut from './keyShortcut';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
|
|
||||||
export default boot(({ app }) => {
|
export default boot(({ app }) => {
|
||||||
app.mixin(qFormMixin);
|
app.mixin(qFormMixin);
|
||||||
app.mixin(mainShortcutMixin);
|
|
||||||
app.directive('shortcut', keyShortcut);
|
app.directive('shortcut', keyShortcut);
|
||||||
app.config.errorHandler = function (err) {
|
app.config.errorHandler = function (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|
|
@ -1,7 +1,44 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import Navbar from 'src/components/NavBar.vue';
|
import Navbar from 'src/components/NavBar.vue';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
import routes from 'src/router/modules';
|
||||||
|
import { onMounted } from 'vue';
|
||||||
|
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
let isNotified = false;
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
const keyBindingMap = routes
|
||||||
|
.filter((route) => route.meta.keyBinding)
|
||||||
|
.reduce((map, route) => {
|
||||||
|
map['Key' + route.meta.keyBinding.toUpperCase()] = route.path;
|
||||||
|
return map;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
const handleKeyDown = (event) => {
|
||||||
|
const { ctrlKey, altKey, code } = event;
|
||||||
|
|
||||||
|
if (ctrlKey && altKey && keyBindingMap[code] && !isNotified) {
|
||||||
|
event.preventDefault();
|
||||||
|
router.push(keyBindingMap[code]);
|
||||||
|
isNotified = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleKeyUp = (event) => {
|
||||||
|
const { ctrlKey, altKey } = event;
|
||||||
|
|
||||||
|
if (!ctrlKey || !altKey) {
|
||||||
|
isNotified = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('keydown', handleKeyDown);
|
||||||
|
window.addEventListener('keyup', handleKeyUp);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
Loading…
Reference in New Issue