Compare commits
3 Commits
b26f5d2bde
...
a14e7e947e
Author | SHA1 | Date |
---|---|---|
Lykin | a14e7e947e | |
Lykin | 868b0c81b6 | |
Lykin | a3cb09863a |
|
@ -156,16 +156,17 @@ func (b *browserService) OpenConnection(name string) (resp types.JSResp) {
|
|||
} else {
|
||||
// get database info
|
||||
var res string
|
||||
res, err = client.Info(ctx, "keyspace").Result()
|
||||
if err != nil {
|
||||
resp.Msg = "get server info fail:" + err.Error()
|
||||
return
|
||||
info := map[string]map[string]string{}
|
||||
if res, err = client.Info(ctx, "keyspace").Result(); err != nil {
|
||||
//resp.Msg = "get server info fail:" + err.Error()
|
||||
//return
|
||||
} else {
|
||||
info = b.parseInfo(res)
|
||||
}
|
||||
info := b.parseInfo(res)
|
||||
|
||||
if totaldb <= 0 {
|
||||
// cannot retrieve the database count by "CONFIG GET databases", try to get max index from keyspace
|
||||
keyspace := info["Keyspace"]
|
||||
if keyspace := info["Keyspace"]; len(keyspace) > 0 {
|
||||
var db, maxDB int
|
||||
for dbName := range keyspace {
|
||||
if db, err = strconv.Atoi(strings.TrimLeft(dbName, "db")); err == nil {
|
||||
|
@ -176,6 +177,7 @@ func (b *browserService) OpenConnection(name string) (resp types.JSResp) {
|
|||
}
|
||||
totaldb = maxDB + 1
|
||||
}
|
||||
}
|
||||
|
||||
queryDB := func(idx int) types.ConnectionDB {
|
||||
dbName := "db" + strconv.Itoa(idx)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script setup>
|
||||
import ContentPane from './components/content/ContentPane.vue'
|
||||
import BrowserPane from './components/sidebar/BrowserPane.vue'
|
||||
import { computed, onMounted, reactive, ref, watchEffect } from 'vue'
|
||||
import { computed, onMounted, onUnmounted, reactive, ref, watchEffect } from 'vue'
|
||||
import { debounce } from 'lodash'
|
||||
import { useThemeVars } from 'naive-ui'
|
||||
import Ribbon from './components/sidebar/Ribbon.vue'
|
||||
|
@ -117,12 +117,18 @@ onMounted(async () => {
|
|||
onToggleFullscreen(fullscreen === true)
|
||||
const maximised = await WindowIsMaximised()
|
||||
onToggleMaximize(maximised)
|
||||
window.addEventListener('keydown', onKeyShortcut)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('keydown', onKeyShortcut)
|
||||
})
|
||||
|
||||
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
|
||||
|
@ -138,7 +144,7 @@ const onKeyShortcut = (e) => {
|
|||
<template>
|
||||
<!-- app content-->
|
||||
<n-spin :show="props.loading" :style="spinStyle" :theme-overrides="{ opacitySpinning: 0 }">
|
||||
<div id="app-content-wrapper" :style="wrapperStyle" class="flex-box-v" tabindex="0" @keydown="onKeyShortcut">
|
||||
<div id="app-content-wrapper" :style="wrapperStyle" class="flex-box-v">
|
||||
<!-- title bar -->
|
||||
<div
|
||||
id="app-toolbar"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue