diff --git a/src/boot/mainShortcutMixin.js b/src/boot/mainShortcutMixin.js index 3b5c604b7..8e5f147db 100644 --- a/src/boot/mainShortcutMixin.js +++ b/src/boot/mainShortcutMixin.js @@ -9,16 +9,16 @@ export default { const keyBindingMap = routes .filter((route) => route.meta.keyBinding) .reduce((map, route) => { - map[route.meta.keyBinding.toLowerCase()] = route.path; + map['Key' + route.meta.keyBinding.toUpperCase()] = route.path; return map; }, {}); const handleKeyDown = (event) => { - const { ctrlKey, altKey, key } = event; + const { ctrlKey, altKey, code } = event; - if (ctrlKey && altKey && keyBindingMap[key] && !isNotified) { + if (ctrlKey && altKey && keyBindingMap[code] && !isNotified) { event.preventDefault(); - router.push(keyBindingMap[key]); + router.push(keyBindingMap[code]); isNotified = true; } }; diff --git a/src/components/LeftMenuItem.vue b/src/components/LeftMenuItem.vue index f3f2315a3..9fe66e278 100644 --- a/src/components/LeftMenuItem.vue +++ b/src/components/LeftMenuItem.vue @@ -33,7 +33,12 @@ const itemComputed = computed(() => { - {{ t(itemComputed.title) }} + + {{ t(itemComputed.title) }} + + {{ 'Ctrl + Alt + ' + item.keyBinding.toUpperCase() }} + + diff --git a/src/pages/Dashboard/DashboardMain.vue b/src/pages/Dashboard/DashboardMain.vue index 6da39ce25..a339120e2 100644 --- a/src/pages/Dashboard/DashboardMain.vue +++ b/src/pages/Dashboard/DashboardMain.vue @@ -55,6 +55,15 @@ const pinnedModules = computed(() => navigation.getPinnedModules()); >
{{ t(item.title) }} +
+ {{ '(' + item.keyBinding + ')' }} + + {{ + 'Ctrl + Alt + ' + + item.keyBinding.toUpperCase() + }} + +
diff --git a/src/router/modules/Supplier.js b/src/router/modules/Supplier.js index b711066b2..143d7c824 100644 --- a/src/router/modules/Supplier.js +++ b/src/router/modules/Supplier.js @@ -7,6 +7,7 @@ export default { title: 'suppliers', icon: 'vn:supplier', moduleName: 'Supplier', + keyBinding: 'p', }, component: RouterView, redirect: { name: 'SupplierMain' }, diff --git a/src/router/modules/account.js b/src/router/modules/account.js index cfec2b95d..34f804b18 100644 --- a/src/router/modules/account.js +++ b/src/router/modules/account.js @@ -7,6 +7,7 @@ export default { title: 'users', icon: 'face', moduleName: 'Account', + keyBinding: 'u', }, component: RouterView, redirect: { name: 'AccountMain' }, diff --git a/src/router/modules/claim.js b/src/router/modules/claim.js index cced9e24d..d597267b2 100644 --- a/src/router/modules/claim.js +++ b/src/router/modules/claim.js @@ -7,6 +7,7 @@ export default { title: 'claims', icon: 'vn:claims', moduleName: 'Claim', + keyBinding: 'r', }, component: RouterView, redirect: { name: 'ClaimMain' }, diff --git a/src/router/modules/customer.js b/src/router/modules/customer.js index 684b83b0f..5b73ddc84 100644 --- a/src/router/modules/customer.js +++ b/src/router/modules/customer.js @@ -7,6 +7,7 @@ export default { title: 'customers', icon: 'vn:client', moduleName: 'Customer', + keyBinding: 'c', }, component: RouterView, redirect: { name: 'CustomerMain' }, diff --git a/src/router/modules/entry.js b/src/router/modules/entry.js index 0d38ed626..365615b87 100644 --- a/src/router/modules/entry.js +++ b/src/router/modules/entry.js @@ -7,6 +7,7 @@ export default { title: 'entries', icon: 'vn:entry', moduleName: 'Entry', + keyBinding: 'e', }, component: RouterView, redirect: { name: 'EntryMain' }, diff --git a/src/router/modules/item.js b/src/router/modules/item.js index 4bd5df4e2..48e19dd54 100644 --- a/src/router/modules/item.js +++ b/src/router/modules/item.js @@ -7,6 +7,7 @@ export default { title: 'items', icon: 'vn:item', moduleName: 'Item', + keyBinding: 'a', }, component: RouterView, redirect: { name: 'ItemMain' }, diff --git a/src/router/modules/monitor.js b/src/router/modules/monitor.js index 3353da3cf..7342a5904 100644 --- a/src/router/modules/monitor.js +++ b/src/router/modules/monitor.js @@ -7,6 +7,7 @@ export default { title: 'monitors', icon: 'grid_view', moduleName: 'Monitor', + keyBinding: 'm', }, component: RouterView, redirect: { name: 'MonitorMain' }, diff --git a/src/router/modules/order.js b/src/router/modules/order.js index 9ccdb820b..bfa37fce5 100644 --- a/src/router/modules/order.js +++ b/src/router/modules/order.js @@ -7,6 +7,7 @@ export default { title: 'order', icon: 'vn:basket', moduleName: 'Order', + keyBinding: 'o', }, component: RouterView, redirect: { name: 'OrderMain' }, diff --git a/src/router/modules/route.js b/src/router/modules/route.js index 955fc9098..3c5c860cf 100644 --- a/src/router/modules/route.js +++ b/src/router/modules/route.js @@ -7,7 +7,6 @@ export default { title: 'routes', icon: 'vn:delivery', moduleName: 'Route', - keyBinding: 'r', }, component: RouterView, redirect: { name: 'RouteMain' }, diff --git a/src/router/modules/ticket.js b/src/router/modules/ticket.js index 4074f089f..0f6fc9b22 100644 --- a/src/router/modules/ticket.js +++ b/src/router/modules/ticket.js @@ -7,6 +7,7 @@ export default { title: 'tickets', icon: 'vn:ticket', moduleName: 'Ticket', + keyBinding: 't', }, component: RouterView, redirect: { name: 'TicketMain' }, diff --git a/src/router/modules/worker.js b/src/router/modules/worker.js index 2a523e7fe..b2716474b 100644 --- a/src/router/modules/worker.js +++ b/src/router/modules/worker.js @@ -7,6 +7,7 @@ export default { title: 'workers', icon: 'vn:worker', moduleName: 'Worker', + keyBinding: 'w', }, component: RouterView, redirect: { name: 'WorkerMain' }, diff --git a/src/router/modules/zone.js b/src/router/modules/zone.js index 40358c58e..1f27cc76f 100644 --- a/src/router/modules/zone.js +++ b/src/router/modules/zone.js @@ -7,6 +7,7 @@ export default { title: 'zones', icon: 'vn:zone', moduleName: 'Zone', + keyBinding: 'z', }, component: RouterView, redirect: { name: 'ZoneMain' }, diff --git a/src/stores/useNavigationStore.js b/src/stores/useNavigationStore.js index 961e80377..4589426f8 100644 --- a/src/stores/useNavigationStore.js +++ b/src/stores/useNavigationStore.js @@ -72,6 +72,7 @@ export const useNavigationStore = defineStore('navigationStore', () => { if (meta) { item.title = `globals.pageTitles.${meta.title}`; item.icon = meta.icon; + item.keyBinding = meta.keyBinding; } parent.push(item); diff --git a/test/cypress/integration/vnComponent/VnShortcut.spec.js b/test/cypress/integration/vnComponent/VnShortcut.spec.js new file mode 100644 index 000000000..b49b4e964 --- /dev/null +++ b/test/cypress/integration/vnComponent/VnShortcut.spec.js @@ -0,0 +1,33 @@ +/// + +describe('VnShortcuts', () => { + const modules = { + item: 'a', + customer: 'c', + ticket: 't', + claim: 'r', + worker: 'w', + monitor: 'm', + order: 'o', + supplier: 'p', + entry: 'e', + zone: 'z', + account: 'u', + }; + beforeEach(() => { + cy.login('developer'); + cy.visit('/'); + }); + + for (const [module, shortcut] of Object.entries(modules)) { + it(`should visit ${module} module`, () => { + cy.get('body').trigger('keydown', { + ctrlKey: true, + altKey: true, + code: `Key${shortcut.toUpperCase()}`, + }); + + cy.url().should('include', module); + }); + } +});