From 6d3526c765d4385765739a880365cf98e78e4fd9 Mon Sep 17 00:00:00 2001 From: Lykin <137850705+tiny-craft@users.noreply.github.com> Date: Thu, 18 Jan 2024 17:15:34 +0800 Subject: [PATCH] feat: support database alias --- backend/services/browser_service.go | 5 ++ backend/types/connection.go | 2 + .../components/dialogs/ConnectionDialog.vue | 85 +++++++++++++++++-- .../src/components/new_value/AddZSetValue.vue | 5 -- .../src/components/sidebar/BrowserPane.vue | 24 ++++-- frontend/src/langs/en-us.json | 5 ++ frontend/src/langs/zh-cn.json | 5 ++ frontend/src/objects/redisDatabaseItem.js | 3 +- frontend/src/stores/browser.js | 1 + frontend/src/stores/connections.js | 1 + 10 files changed, 114 insertions(+), 22 deletions(-) diff --git a/backend/services/browser_service.go b/backend/services/browser_service.go index 0edce5a..b5220f8 100644 --- a/backend/services/browser_service.go +++ b/backend/services/browser_service.go @@ -179,8 +179,13 @@ func (b *browserService) OpenConnection(name string) (resp types.JSResp) { dbInfoStr := info["Keyspace"][dbName] if len(dbInfoStr) > 0 { dbInfo := b.parseDBItemInfo(dbInfoStr) + var alias string + if selConn.Alias != nil { + alias = selConn.Alias[idx] + } return types.ConnectionDB{ Name: dbName, + Alias: alias, Index: idx, MaxKeys: dbInfo["keys"], Expires: dbInfo["expires"], diff --git a/backend/types/connection.go b/backend/types/connection.go index dbebb3a..dcdfb37 100644 --- a/backend/types/connection.go +++ b/backend/types/connection.go @@ -20,6 +20,7 @@ type ConnectionConfig struct { LoadSize int `json:"loadSize,omitempty" yaml:"load_size,omitempty"` MarkColor string `json:"markColor,omitempty" yaml:"mark_color,omitempty"` RefreshInterval int `json:"refreshInterval,omitempty" yaml:"refreshInterval,omitempty"` + Alias map[int]string `json:"alias,omitempty" yaml:"alias,omitempty"` SSL ConnectionSSL `json:"ssl,omitempty" yaml:"ssl,omitempty"` SSH ConnectionSSH `json:"ssh,omitempty" yaml:"ssh,omitempty"` Sentinel ConnectionSentinel `json:"sentinel,omitempty" yaml:"sentinel,omitempty"` @@ -36,6 +37,7 @@ type Connections []Connection type ConnectionDB struct { Name string `json:"name"` + Alias string `json:"alias,omitempty"` Index int `json:"index"` MaxKeys int `json:"maxKeys"` Expires int `json:"expires,omitempty"` diff --git a/frontend/src/components/dialogs/ConnectionDialog.vue b/frontend/src/components/dialogs/ConnectionDialog.vue index 511f93e..a4aad56 100644 --- a/frontend/src/components/dialogs/ConnectionDialog.vue +++ b/frontend/src/components/dialogs/ConnectionDialog.vue @@ -1,5 +1,5 @@