From c4f1a2e1784657c9c38d1893b3ac2ba8dd155741 Mon Sep 17 00:00:00 2001 From: tiny-craft <137850705+tiny-craft@users.noreply.github.com> Date: Tue, 18 Jul 2023 10:40:34 +0800 Subject: [PATCH] feat: add key type filter setting perf: add closing connection status in edit connection dialog --- backend/services/connection_service.go | 14 +- .../src/components/common/RedisTypeTag.vue | 22 +- .../content_value/ContentValueSet.vue | 2 +- .../components/dialogs/ConnectionDialog.vue | 210 ++++++++++-------- .../components/dialogs/KeyFilterDialog.vue | 25 ++- .../src/components/sidebar/BrowserTree.vue | 64 ++++-- .../src/components/sidebar/ConnectionTree.vue | 9 +- frontend/src/consts/support_redis_type.js | 8 + frontend/src/langs/zh-cn.json | 4 +- frontend/src/stores/connections.js | 29 ++- frontend/src/stores/dialog.js | 9 +- 11 files changed, 240 insertions(+), 156 deletions(-) diff --git a/backend/services/connection_service.go b/backend/services/connection_service.go index 41c332c..0facf50 100644 --- a/backend/services/connection_service.go +++ b/backend/services/connection_service.go @@ -347,24 +347,30 @@ func (c *connectionService) ServerInfo(name string) (resp types.JSResp) { // OpenDatabase open select database, and list all keys // @param path contain connection name and db name -func (c *connectionService) OpenDatabase(connName string, db int, match string) (resp types.JSResp) { - return c.ScanKeys(connName, db, match) +func (c *connectionService) OpenDatabase(connName string, db int, match string, keyType string) (resp types.JSResp) { + return c.ScanKeys(connName, db, match, keyType) } // ScanKeys scan all keys -func (c *connectionService) ScanKeys(connName string, db int, match string) (resp types.JSResp) { +func (c *connectionService) ScanKeys(connName string, db int, match, keyType string) (resp types.JSResp) { rdb, ctx, err := c.getRedisClient(connName, db) if err != nil { resp.Msg = err.Error() return } + filterType := len(keyType) > 0 + var keys []string //keys := map[string]keyItem{} var cursor uint64 for { var loadedKey []string - loadedKey, cursor, err = rdb.Scan(ctx, cursor, match, 10000).Result() + if filterType { + loadedKey, cursor, err = rdb.ScanType(ctx, cursor, match, 10000, keyType).Result() + } else { + loadedKey, cursor, err = rdb.Scan(ctx, cursor, match, 10000).Result() + } if err != nil { resp.Msg = err.Error() return diff --git a/frontend/src/components/common/RedisTypeTag.vue b/frontend/src/components/common/RedisTypeTag.vue index d4488df..09e46b7 100644 --- a/frontend/src/components/common/RedisTypeTag.vue +++ b/frontend/src/components/common/RedisTypeTag.vue @@ -1,6 +1,6 @@