diff --git a/backend/services/browser_service.go b/backend/services/browser_service.go index 907cbd6..683b7fa 100644 --- a/backend/services/browser_service.go +++ b/backend/services/browser_service.go @@ -516,6 +516,35 @@ func (b *browserService) LoadAllKeys(connName string, db int, match, keyType str return } +func (b *browserService) GetKeyType(param types.KeySummaryParam) (resp types.JSResp) { + item, err := b.getRedisClient(param.Server, param.DB) + if err != nil { + resp.Msg = err.Error() + return + } + + client, ctx := item.client, item.ctx + key := strutil.DecodeRedisKey(param.Key) + var keyType string + keyType, err = client.Type(ctx, key).Result() + if err != nil { + resp.Msg = err.Error() + return + } + + if keyType == "none" { + resp.Msg = "key not exists" + return + } + + var data types.KeySummary + data.Type = strings.ToLower(keyType) + + resp.Success = true + resp.Data = data + return +} + // GetKeySummary get key summary info func (b *browserService) GetKeySummary(param types.KeySummaryParam) (resp types.JSResp) { item, err := b.getRedisClient(param.Server, param.DB) diff --git a/backend/types/js_resp.go b/backend/types/js_resp.go index ceb4e8a..3e5ef09 100644 --- a/backend/types/js_resp.go +++ b/backend/types/js_resp.go @@ -14,9 +14,9 @@ type KeySummaryParam struct { type KeySummary struct { Type string `json:"type"` - TTL int64 `json:"ttl"` - Size int64 `json:"size"` - Length int64 `json:"length"` + TTL int64 `json:"ttl,omitempty"` + Size int64 `json:"size,omitempty"` + Length int64 `json:"length,omitempty"` } type KeyDetailParam struct { diff --git a/frontend/src/AppContent.vue b/frontend/src/AppContent.vue index d3d6093..1f7faf9 100644 --- a/frontend/src/AppContent.vue +++ b/frontend/src/AppContent.vue @@ -2,7 +2,7 @@ import ContentPane from './components/content/ContentPane.vue' import BrowserPane from './components/sidebar/BrowserPane.vue' import { computed, onMounted, reactive, ref, watch } from 'vue' -import { debounce, get } from 'lodash' +import { debounce } from 'lodash' import { useThemeVars } from 'naive-ui' import Ribbon from './components/sidebar/Ribbon.vue' import ConnectionPane from './components/sidebar/ConnectionPane.vue' @@ -139,7 +139,7 @@ onMounted(async () => {