From 78bfaf6e1685578ad9fd11826dd94e67fa307ec7 Mon Sep 17 00:00:00 2001 From: Lykin <137850705+tiny-craft@users.noreply.github.com> Date: Mon, 20 May 2024 00:30:15 +0800 Subject: [PATCH] perf: support `Ctrl+C`/`Cmd+C` to copy selected key name --- .../src/components/sidebar/BrowserTree.vue | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/frontend/src/components/sidebar/BrowserTree.vue b/frontend/src/components/sidebar/BrowserTree.vue index 62e4835..945c4e3 100644 --- a/frontend/src/components/sidebar/BrowserTree.vue +++ b/frontend/src/components/sidebar/BrowserTree.vue @@ -309,6 +309,29 @@ const handleKeyDelete = () => { } } +const handleKeyCopy = () => { + const selectedKey = get(selectedKeys.value, 0) + if (selectedKey == null) { + return + } + let node = browserStore.getNode(selectedKey) + if (node == null) { + return + } + + if (node.type === ConnectionType.RedisValue) { + ClipboardSetText(nativeRedisKey(node.redisKeyCode || node.redisKey)) + .then((succ) => { + if (succ) { + $message.success(i18n.t('interface.copy_succ')) + } + }) + .catch((e) => { + $message.error(e.message) + }) + } +} + const handleSelectContextMenu = (action) => { contextMenuParam.show = false const selectedKey = get(selectedKeys.value, 0) @@ -786,6 +809,7 @@ defineExpose({ @keydown.left="handleKeyLeft" @keydown.right="handleKeyRight" @keydown.delete="handleKeyDelete" + @keydown.meta.c="handleKeyCopy" @update:selected-keys="onUpdateSelectedKeys" @update:expanded-keys="onUpdateExpanded" @update:checked-keys="onUpdateCheckedKeys">