fix: create key error

This commit is contained in:
Lykin 2024-01-06 22:13:26 +08:00
parent d66d7c9a49
commit ed1b9d9b54
5 changed files with 25 additions and 14 deletions

View File

@ -685,6 +685,7 @@ func (b *browserService) GetKeyDetail(param types.KeyDetailParam) (resp types.JS
} }
var data types.KeyDetail var data types.KeyDetail
data.KeyType = strings.ToLower(keyType)
//var cursor uint64 //var cursor uint64
matchPattern := param.MatchPattern matchPattern := param.MatchPattern
if len(matchPattern) <= 0 { 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": case "string":
var str string var str string
str, err = client.Get(ctx, key).Result() str, err = client.Get(ctx, key).Result()

View File

@ -32,6 +32,7 @@ type KeyDetailParam struct {
type KeyDetail struct { type KeyDetail struct {
Value any `json:"value"` Value any `json:"value"`
KeyType string `json:"key_type"`
Length int64 `json:"length,omitempty"` Length int64 `json:"length,omitempty"`
Format string `json:"format,omitempty"` Format string `json:"format,omitempty"`
Decode string `json:"decode,omitempty"` Decode string `json:"decode,omitempty"`

View File

@ -135,6 +135,7 @@ const onAdd = async () => {
if (value == null) { if (value == null) {
value = defaultValue[type] value = defaultValue[type]
} }
// await browserStore.reloadKey({server, db, key: trim(key)})
const { success, msg, nodeKey } = await browserStore.setKey({ const { success, msg, nodeKey } = await browserStore.setKey({
server, server,
db, db,
@ -147,7 +148,7 @@ const onAdd = async () => {
// select current key // select current key
await nextTick() await nextTick()
tabStore.setSelectedKeys(server, nodeKey) tabStore.setSelectedKeys(server, nodeKey)
browserStore.loadKeySummary({ server, db, key, clearValue: true }) browserStore.reloadKey({ server, db, key })
} else if (!isEmpty(msg)) { } else if (!isEmpty(msg)) {
$message.error(msg) $message.error(msg)
} }

View File

@ -101,7 +101,7 @@ const checkedTip = computed(() => {
const onReload = async () => { const onReload = async () => {
try { try {
loading.value = true loading.value = true
tabStore.setSelectedKeys(props.server) // tabStore.setSelectedKeys(props.server)
const db = props.db const db = props.db
browserStore.closeDatabase(props.server, db) browserStore.closeDatabase(props.server, db)

View File

@ -505,7 +505,15 @@ const useBrowserStore = defineStore('browser', {
lite: true, lite: true,
}) })
if (success) { 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({ tab.updateValue({
server, server,
db, db,
@ -758,10 +766,10 @@ const useBrowserStore = defineStore('browser', {
serverInst.updateDBKeyCount(db, newKey) serverInst.updateDBKeyCount(db, newKey)
} }
} }
const tab = useTabStore() // const tab = useTabStore()
tab.updateValue({ server, db, key, value }) // tab.updateValue({ server, db, key, value })
this.loadKeySummary({ server, db, key }) // this.loadKeySummary({ server, db, key })
return { return {
success, success,
nodeKey: `${server}/db${db}#${ConnectionType.RedisValue}/${key}`, nodeKey: `${server}/db${db}#${ConnectionType.RedisValue}/${key}`,