From f0c9b745456cdce2af3d94ecf172904432855b3f Mon Sep 17 00:00:00 2001 From: Lykin <137850705+tiny-craft@users.noreply.github.com> Date: Sat, 18 May 2024 23:23:48 +0800 Subject: [PATCH] perf: support close tab by shortcut `Command+W`/`Control+W` (#258) --- frontend/src/AppContent.vue | 17 ++++++++++++++++- .../src/components/content/ContentValueTab.vue | 10 +--------- frontend/src/stores/tab.js | 13 +++++++++++++ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/frontend/src/AppContent.vue b/frontend/src/AppContent.vue index fe665d1..dba16a3 100644 --- a/frontend/src/AppContent.vue +++ b/frontend/src/AppContent.vue @@ -110,12 +110,27 @@ onMounted(async () => { const maximised = await WindowIsMaximised() onToggleMaximize(maximised) }) + +const onKeyShortcut = (e) => { + switch (e.key) { + case 'w': + if (e.metaKey) { + // close current tab + const tabStore = useTabStore() + const currentTab = tabStore.currentTab + if (currentTab != null) { + tabStore.closeTab(currentTab.name) + } + } + break + } +}