perf: add shortcut for key operations

This commit is contained in:
Lykin 2024-04-19 16:43:42 +08:00
parent b72855b707
commit 971c89a5cf
2 changed files with 33 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import useDialogStore from 'stores/dialog.js'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import ContentToolbar from '@/components/content_value/ContentToolbar.vue' import ContentToolbar from '@/components/content_value/ContentToolbar.vue'
import ContentValueJson from '@/components/content_value/ContentValueJson.vue' import ContentValueJson from '@/components/content_value/ContentValueJson.vue'
import { isMacOS } from '@/utils/platform.js'
const themeVars = useThemeVars() const themeVars = useThemeVars()
const browserStore = useBrowserStore() 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 onRename = () => {
const { name, db, keyPath } = data.value const { name, db, keyPath } = data.value
if (binaryKey.value) { if (binaryKey.value) {
@ -189,6 +219,8 @@ watch(() => data.value?.keyPath, initContent)
<!-- FIXME: keep alive may cause virtual list null value error. --> <!-- FIXME: keep alive may cause virtual list null value error. -->
<!-- <keep-alive v-else> --> <!-- <keep-alive v-else> -->
<component <component
tabindex="0"
@keydown="onKeyShortcut"
:is="valueComponents[data.type]" :is="valueComponents[data.type]"
v-else v-else
ref="contentRef" ref="contentRef"

View File

@ -598,6 +598,7 @@ defineExpose({
check-strategy="child" check-strategy="child"
class="fill-height" class="fill-height"
virtual-scroll virtual-scroll
@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" />