diff --git a/backend/services/browser_service.go b/backend/services/browser_service.go index d75919f..9d26af9 100644 --- a/backend/services/browser_service.go +++ b/backend/services/browser_service.go @@ -87,7 +87,18 @@ func (b *browserService) Stop() { func (b *browserService) OpenConnection(name string) (resp types.JSResp) { // get connection config selConn := Connection().getConnection(name) - item, err := b.getRedisClient(name, selConn.LastDB) + // correct last database index + lastDB := selConn.LastDB + if selConn.DBFilterType == "show" && !sliceutil.Contains(selConn.DBFilterList, lastDB) { + lastDB = selConn.DBFilterList[0] + } else if selConn.DBFilterType == "hide" && sliceutil.Contains(selConn.DBFilterList, lastDB) { + lastDB = selConn.DBFilterList[0] + } + if lastDB != selConn.LastDB { + Connection().SaveLastDB(name, lastDB) + } + + item, err := b.getRedisClient(name, lastDB) if err != nil { resp.Msg = err.Error() return diff --git a/frontend/src/components/sidebar/BrowserPane.vue b/frontend/src/components/sidebar/BrowserPane.vue index c6560d7..5bb61fc 100644 --- a/frontend/src/components/sidebar/BrowserPane.vue +++ b/frontend/src/components/sidebar/BrowserPane.vue @@ -152,6 +152,10 @@ const onDisconnect = () => { } const handleSelectDB = async (db) => { + if (db === props.db) { + return + } + try { loading.value = true browserStore.setKeyFilter(props.server, {}) diff --git a/frontend/src/components/sidebar/BrowserTree.vue b/frontend/src/components/sidebar/BrowserTree.vue index 1789853..ad853ed 100644 --- a/frontend/src/components/sidebar/BrowserTree.vue +++ b/frontend/src/components/sidebar/BrowserTree.vue @@ -295,7 +295,7 @@ const onUpdateSelectedKeys = (keys, options) => { } } // default is load blank key to display server status - tabStore.openBlank(props.server) + tabStore.openBlank(props.server, props.db) } finally { tabStore.setSelectedKeys(props.server, keys) } diff --git a/frontend/src/components/sidebar/ConnectionTree.vue b/frontend/src/components/sidebar/ConnectionTree.vue index c6b217f..4aa8a46 100644 --- a/frontend/src/components/sidebar/ConnectionTree.vue +++ b/frontend/src/components/sidebar/ConnectionTree.vue @@ -49,13 +49,6 @@ const contextMenuParam = reactive({ currentNode: null, }) -const renderIcon = (icon) => { - return () => { - return h(NIcon, null, { - default: () => h(icon), - }) - } -} const menuOptions = { [ConnectionType.Group]: ({ opened }) => [ { diff --git a/frontend/src/stores/tab.js b/frontend/src/stores/tab.js index 8120564..88b359b 100644 --- a/frontend/src/stores/tab.js +++ b/frontend/src/stores/tab.js @@ -151,7 +151,7 @@ const useTabStore = defineStore('tab', { }, openBlank(server) { - this.upsertTab({ server, db: 0 }) + this.upsertTab({ server }) }, /** @@ -194,7 +194,7 @@ const useTabStore = defineStore('tab', { // tab.title = db !== undefined ? `${server}/db${db}` : `${server}` tab.title = server tab.server = server - tab.db = db + tab.db = db == null ? tab.db : db tab.type = type tab.ttl = ttl tab.key = key