From 971c89a5cfcc6de4a5b6cadc048fbc6c44713eed Mon Sep 17 00:00:00 2001 From: Lykin <137850705+tiny-craft@users.noreply.github.com> Date: Fri, 19 Apr 2024 16:43:42 +0800 Subject: [PATCH] perf: add shortcut for key operations --- .../content_value/ContentValueWrapper.vue | 32 +++++++++++++++++++ .../src/components/sidebar/BrowserTree.vue | 1 + 2 files changed, 33 insertions(+) diff --git a/frontend/src/components/content_value/ContentValueWrapper.vue b/frontend/src/components/content_value/ContentValueWrapper.vue index 508f281..29be172 100644 --- a/frontend/src/components/content_value/ContentValueWrapper.vue +++ b/frontend/src/components/content_value/ContentValueWrapper.vue @@ -14,6 +14,7 @@ import useDialogStore from 'stores/dialog.js' import { useI18n } from 'vue-i18n' import ContentToolbar from '@/components/content_value/ContentToolbar.vue' import ContentValueJson from '@/components/content_value/ContentValueJson.vue' +import { isMacOS } from '@/utils/platform.js' const themeVars = useThemeVars() const browserStore = useBrowserStore() @@ -126,6 +127,35 @@ const onReload = async (selDecode, selFormat) => { } } +const onKeyShortcut = (e) => { + // console.log(e) + switch (e.key) { + case 'Delete': + onDelete() + return + + case 'd': + if (e.metaKey) { + onDelete() + } + return + + case 'F5': + onReload() + return + + case 'r': + if (e.metaKey && isMacOS()) { + onReload() + } + return + + case 'F2': + onRename() + return + } +} + const onRename = () => { const { name, db, keyPath } = data.value if (binaryKey.value) { @@ -189,6 +219,8 @@ watch(() => data.value?.keyPath, initContent)