fix: compatible with non-macOS when the shortcut key contains `metaKey`

This commit is contained in:
Lykin 2024-08-07 10:14:59 +08:00
parent a3cb09863a
commit 868b0c81b6
3 changed files with 9 additions and 5 deletions

View File

@ -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

View File

@ -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()
@ -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()
@ -139,7 +140,7 @@ const onKeyShortcut = (e) => {
onReload()
return
case 'r':
if (e.metaKey) {
if (isCtrlOn) {
onReload()
}
return

View File

@ -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,
@ -326,6 +327,7 @@ const handleKeyCopy = () => {
}
const onKeyShortcut = (e) => {
const isCtrlOn = isMacOS() ? e.metaKey : e.ctrlKey
switch (e.key) {
case 'ArrowUp':
handleKeyUp()
@ -340,7 +342,7 @@ const onKeyShortcut = (e) => {
handleKeyRight()
break
case 'c':
if (e.metaKey) {
if (isCtrlOn) {
handleKeyCopy()
}
break
@ -351,7 +353,7 @@ const onKeyShortcut = (e) => {
handleSelectContextMenu('value_reload')
break
case 'r':
if (e.metaKey) {
if (isCtrlOn) {
handleSelectContextMenu('value_reload')
}
break