Skip to content

Commit

Permalink
perf: add shortcut for key operations
Browse files Browse the repository at this point in the history
  • Loading branch information
tiny-craft committed Apr 19, 2024
1 parent b72855b commit 971c89a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions frontend/src/components/content_value/ContentValueWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -189,6 +219,8 @@ watch(() => data.value?.keyPath, initContent)
<!-- FIXME: keep alive may cause virtual list null value error. -->
<!-- <keep-alive v-else> -->
<component
tabindex="0"
@keydown="onKeyShortcut"
:is="valueComponents[data.type]"
v-else
ref="contentRef"
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/sidebar/BrowserTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ defineExpose({
check-strategy="child"
class="fill-height"
virtual-scroll
@keydown.delete="handleSelectContextMenu('value_remove')"
@update:selected-keys="onUpdateSelectedKeys"
@update:expanded-keys="onUpdateExpanded"
@update:checked-keys="onUpdateCheckedKeys" />
Expand Down

0 comments on commit 971c89a

Please sign in to comment.