Skip to content

Commit

Permalink
fix: compatible with non-macOS when the shortcut key contains metaKey
Browse files Browse the repository at this point in the history
  • Loading branch information
tiny-craft committed Aug 7, 2024
1 parent a3cb098 commit 868b0c8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion frontend/src/AppContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ onUnmounted(() => {
})
const onKeyShortcut = (e) => {
const isCtrlOn = isMacOS() ? e.metaKey : e.ctrlKey
switch (e.key) {
case 'w':
if (e.metaKey) {
if (isCtrlOn) {
// close current tab
const tabStore = useTabStore()
const currentTab = tabStore.currentTab
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/content_value/ContentValueWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import ContentToolbar from '@/components/content_value/ContentToolbar.vue'
import ContentValueJson from '@/components/content_value/ContentValueJson.vue'
import usePreferencesStore from 'stores/preferences.js'
import { TextAlignType } from '@/consts/text_align_type.js'
import { isMacOS } from '@/utils/platform.js'
const themeVars = useThemeVars()
const browserStore = useBrowserStore()
Expand Down Expand Up @@ -130,7 +131,7 @@ const onReload = async (selDecode, selFormat) => {
}
const onKeyShortcut = (e) => {
// console.log(e)
const isCtrlOn = isMacOS() ? e.metaKey : e.ctrlKey
switch (e.key) {
case 'Delete':
onDelete()
Expand All @@ -139,7 +140,7 @@ const onKeyShortcut = (e) => {
onReload()
return
case 'r':
if (e.metaKey) {
if (isCtrlOn) {
onReload()
}
return
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/components/sidebar/BrowserTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import usePreferencesStore from 'stores/preferences.js'
import { typesIconStyle } from '@/consts/support_redis_type.js'
import { nativeRedisKey } from '@/utils/key_convert.js'
import copy from 'copy-text-to-clipboard'
import { isMacOS } from '@/utils/platform.js'
const props = defineProps({
server: String,
Expand Down Expand Up @@ -326,6 +327,7 @@ const handleKeyCopy = () => {
}
const onKeyShortcut = (e) => {
const isCtrlOn = isMacOS() ? e.metaKey : e.ctrlKey
switch (e.key) {
case 'ArrowUp':
handleKeyUp()
Expand All @@ -340,7 +342,7 @@ const onKeyShortcut = (e) => {
handleKeyRight()
break
case 'c':
if (e.metaKey) {
if (isCtrlOn) {
handleKeyCopy()
}
break
Expand All @@ -351,7 +353,7 @@ const onKeyShortcut = (e) => {
handleSelectContextMenu('value_reload')
break
case 'r':
if (e.metaKey) {
if (isCtrlOn) {
handleSelectContextMenu('value_reload')
}
break
Expand Down

0 comments on commit 868b0c8

Please sign in to comment.