fix: can not switch to an open connection from connection tree view

This commit is contained in:
Lykin 2025-01-07 16:24:12 +08:00
parent 6e44c64441
commit edd77182a5
2 changed files with 6 additions and 0 deletions

View File

@ -295,6 +295,7 @@ const openConnection = async (name) => {
tabStore.upsertTab({ tabStore.upsertTab({
server: name, server: name,
db: browserStore.getSelectedDB(name), db: browserStore.getSelectedDB(name),
forceSwitch: true,
}) })
} }
} catch (e) { } catch (e) {

View File

@ -161,6 +161,7 @@ const useTabStore = defineStore('tab', {
* @param {boolean} [clearValue] * @param {boolean} [clearValue]
* @param {string} format * @param {string} format
* @param {string} decode * @param {string} decode
* @param {boolean} forceSwitch
* @param {*} [value] * @param {*} [value]
*/ */
upsertTab({ upsertTab({
@ -177,6 +178,7 @@ const useTabStore = defineStore('tab', {
clearValue, clearValue,
format = '', format = '',
decode = '', decode = '',
forceSwitch = false,
}) { }) {
let tabIndex = findIndex(this.tabList, { name: server }) let tabIndex = findIndex(this.tabList, { name: server })
if (tabIndex === -1) { if (tabIndex === -1) {
@ -221,6 +223,9 @@ const useTabStore = defineStore('tab', {
if (clearValue === true) { if (clearValue === true) {
tab.value = undefined tab.value = undefined
} }
if (forceSwitch === true) {
this._setActivatedIndex(tabIndex, true, subTab)
}
} }
}, },