Compare commits

..

No commits in common. "3c43f960c3a0d4068a357d6700b90ec322108c42" and "f0c9b745456cdce2af3d94ecf172904432855b3f" have entirely different histories.

2 changed files with 6 additions and 93 deletions

View File

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

View File

@ -26,7 +26,6 @@ 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,
@ -281,96 +280,6 @@ const handleKeyRight = () => {
} }
} }
const handleKeyDelete = () => {
const selectedKey = get(selectedKeys.value, 0)
if (selectedKey == null) {
return
}
let node = browserStore.getNode(selectedKey)
if (node == null) {
return
}
const { db = 0, key: nodeKey, redisKey: rk = '', redisKeyCode: rkc, label } = node || {}
const redisKey = rkc || rk
const redisKeyName = !!rkc ? label : redisKey
switch (node.type) {
case ConnectionType.RedisKey:
dialogStore.openDeleteKeyDialog(props.server, db, isEmpty(redisKey) ? '*' : redisKey + ':*')
break
case ConnectionType.RedisValue:
$dialog.warning(i18n.t('dialogue.remove_tip', { name: redisKeyName }), () => {
browserStore.deleteKey(props.server, db, redisKey).then((success) => {
if (success) {
$message.success(i18n.t('dialogue.delete.success', { key: redisKeyName }))
}
})
})
break
}
}
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 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)
@ -843,7 +752,11 @@ defineExpose({
class="fill-height" class="fill-height"
virtual-scroll virtual-scroll
:keyboard="false" :keyboard="false"
@keydown="onKeyShortcut" @keydown.up="handleKeyUp"
@keydown.down="handleKeyDown"
@keydown.left="handleKeyLeft"
@keydown.right="handleKeyRight"
@keydown.delete="handleSelectContextMenu('value_remove')"
@update:selected-keys="onUpdateSelectedKeys" @update:selected-keys="onUpdateSelectedKeys"
@update:expanded-keys="onUpdateExpanded" @update:expanded-keys="onUpdateExpanded"
@update:checked-keys="onUpdateCheckedKeys"> @update:checked-keys="onUpdateCheckedKeys">