perf: support `F5`/`Cmd+R` to refresh selected key in key tree view

This commit is contained in:
Lykin 2024-05-20 00:44:55 +08:00
parent 78bfaf6e16
commit 3c43f960c3
2 changed files with 41 additions and 7 deletions

View File

@ -135,7 +135,7 @@ const onKeyShortcut = (e) => {
return return
case 'd': case 'd':
if (e.metaKey) { if (e.metaKey && isMacOS()) {
onDelete() onDelete()
} }
return return

View File

@ -26,6 +26,7 @@ import RedisTypeTag from '@/components/common/RedisTypeTag.vue'
import usePreferencesStore from 'stores/preferences.js' import usePreferencesStore from 'stores/preferences.js'
import { typesIconStyle } from '@/consts/support_redis_type.js' import { typesIconStyle } from '@/consts/support_redis_type.js'
import { nativeRedisKey } from '@/utils/key_convert.js' import { nativeRedisKey } from '@/utils/key_convert.js'
import { isMacOS } from '@/utils/platform.js'
const props = defineProps({ const props = defineProps({
server: String, server: String,
@ -332,6 +333,44 @@ const handleKeyCopy = () => {
} }
} }
const onKeyShortcut = (e) => {
switch (e.key) {
case 'ArrowUp':
handleKeyUp()
break
case 'ArrowDown':
handleKeyDown()
break
case 'ArrowLeft':
handleKeyLeft()
break
case 'ArrowRight':
handleKeyRight()
break
case 'c':
if (e.metaKey) {
handleKeyCopy()
}
break
case 'Delete':
handleKeyDelete()
break
case 'd':
if (e.metaKey && isMacOS()) {
handleKeyDelete()
}
break
case 'F5':
handleSelectContextMenu('value_reload')
break
case 'r':
if (e.metaKey && isMacOS()) {
handleSelectContextMenu('value_reload')
}
break
}
}
const handleSelectContextMenu = (action) => { const handleSelectContextMenu = (action) => {
contextMenuParam.show = false contextMenuParam.show = false
const selectedKey = get(selectedKeys.value, 0) const selectedKey = get(selectedKeys.value, 0)
@ -804,12 +843,7 @@ defineExpose({
class="fill-height" class="fill-height"
virtual-scroll virtual-scroll
:keyboard="false" :keyboard="false"
@keydown.up="handleKeyUp" @keydown="onKeyShortcut"
@keydown.down="handleKeyDown"
@keydown.left="handleKeyLeft"
@keydown.right="handleKeyRight"
@keydown.delete="handleKeyDelete"
@keydown.meta.c="handleKeyCopy"
@update:selected-keys="onUpdateSelectedKeys" @update:selected-keys="onUpdateSelectedKeys"
@update:expanded-keys="onUpdateExpanded" @update:expanded-keys="onUpdateExpanded"
@update:checked-keys="onUpdateCheckedKeys"> @update:checked-keys="onUpdateCheckedKeys">