From ed1b9d9b54cf0c4212bd4a61bfb40a64ecada853 Mon Sep 17 00:00:00 2001 From: Lykin <137850705+tiny-craft@users.noreply.github.com> Date: Sat, 6 Jan 2024 22:13:26 +0800 Subject: [PATCH] fix: create key error --- backend/services/browser_service.go | 3 ++- backend/types/js_resp.go | 15 ++++++++------- frontend/src/components/dialogs/NewKeyDialog.vue | 3 ++- frontend/src/components/sidebar/BrowserPane.vue | 2 +- frontend/src/stores/browser.js | 16 ++++++++++++---- 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/backend/services/browser_service.go b/backend/services/browser_service.go index cdc4198..b1500a5 100644 --- a/backend/services/browser_service.go +++ b/backend/services/browser_service.go @@ -685,6 +685,7 @@ func (b *browserService) GetKeyDetail(param types.KeyDetailParam) (resp types.JS } var data types.KeyDetail + data.KeyType = strings.ToLower(keyType) //var cursor uint64 matchPattern := param.MatchPattern if len(matchPattern) <= 0 { @@ -728,7 +729,7 @@ func (b *browserService) GetKeyDetail(param types.KeyDetailParam) (resp types.JS } } - switch strings.ToLower(keyType) { + switch data.KeyType { case "string": var str string str, err = client.Get(ctx, key).Result() diff --git a/backend/types/js_resp.go b/backend/types/js_resp.go index 3e5ef09..77c5fa2 100644 --- a/backend/types/js_resp.go +++ b/backend/types/js_resp.go @@ -31,13 +31,14 @@ type KeyDetailParam struct { } type KeyDetail struct { - Value any `json:"value"` - Length int64 `json:"length,omitempty"` - Format string `json:"format,omitempty"` - Decode string `json:"decode,omitempty"` - Match string `json:"match,omitempty"` - Reset bool `json:"reset"` - End bool `json:"end"` + Value any `json:"value"` + KeyType string `json:"key_type"` + Length int64 `json:"length,omitempty"` + Format string `json:"format,omitempty"` + Decode string `json:"decode,omitempty"` + Match string `json:"match,omitempty"` + Reset bool `json:"reset"` + End bool `json:"end"` } type SetKeyParam struct { diff --git a/frontend/src/components/dialogs/NewKeyDialog.vue b/frontend/src/components/dialogs/NewKeyDialog.vue index b012108..cce9a9c 100644 --- a/frontend/src/components/dialogs/NewKeyDialog.vue +++ b/frontend/src/components/dialogs/NewKeyDialog.vue @@ -135,6 +135,7 @@ const onAdd = async () => { if (value == null) { value = defaultValue[type] } + // await browserStore.reloadKey({server, db, key: trim(key)}) const { success, msg, nodeKey } = await browserStore.setKey({ server, db, @@ -147,7 +148,7 @@ const onAdd = async () => { // select current key await nextTick() tabStore.setSelectedKeys(server, nodeKey) - browserStore.loadKeySummary({ server, db, key, clearValue: true }) + browserStore.reloadKey({ server, db, key }) } else if (!isEmpty(msg)) { $message.error(msg) } diff --git a/frontend/src/components/sidebar/BrowserPane.vue b/frontend/src/components/sidebar/BrowserPane.vue index 4e992bb..4c73c89 100644 --- a/frontend/src/components/sidebar/BrowserPane.vue +++ b/frontend/src/components/sidebar/BrowserPane.vue @@ -101,7 +101,7 @@ const checkedTip = computed(() => { const onReload = async () => { try { loading.value = true - tabStore.setSelectedKeys(props.server) + // tabStore.setSelectedKeys(props.server) const db = props.db browserStore.closeDatabase(props.server, db) diff --git a/frontend/src/stores/browser.js b/frontend/src/stores/browser.js index f9a94b1..aee37d5 100644 --- a/frontend/src/stores/browser.js +++ b/frontend/src/stores/browser.js @@ -505,7 +505,15 @@ const useBrowserStore = defineStore('browser', { lite: true, }) if (success) { - const { value, decode: retDecode, format: retFormat, match: retMatch, reset: retReset, end } = data + const { + value, + keyType, + decode: retDecode, + format: retFormat, + match: retMatch, + reset: retReset, + end, + } = data tab.updateValue({ server, db, @@ -758,10 +766,10 @@ const useBrowserStore = defineStore('browser', { serverInst.updateDBKeyCount(db, newKey) } } - const tab = useTabStore() - tab.updateValue({ server, db, key, value }) + // const tab = useTabStore() + // tab.updateValue({ server, db, key, value }) - this.loadKeySummary({ server, db, key }) + // this.loadKeySummary({ server, db, key }) return { success, nodeKey: `${server}/db${db}#${ConnectionType.RedisValue}/${key}`,