diff --git a/frontend/src/store/interface/index.ts b/frontend/src/store/interface/index.ts index 498ceb6f3fa1..09e670dcaa1b 100644 --- a/frontend/src/store/interface/index.ts +++ b/frontend/src/store/interface/index.ts @@ -44,6 +44,7 @@ export interface GlobalState { device: DeviceType; lastFilePath: string; currentDB: string; + currentPgDB: string; currentRedisDB: string; showEntranceWarn: boolean; defaultNetwork: string; diff --git a/frontend/src/store/modules/global.ts b/frontend/src/store/modules/global.ts index 4d370fd9c847..53eb2e2ca6e8 100644 --- a/frontend/src/store/modules/global.ts +++ b/frontend/src/store/modules/global.ts @@ -38,6 +38,7 @@ const GlobalStore = defineStore({ device: DeviceType.Desktop, lastFilePath: '', currentDB: '', + currentPgDB: '', currentRedisDB: '', showEntranceWarn: true, defaultNetwork: 'all', @@ -110,6 +111,9 @@ const GlobalStore = defineStore({ setCurrentDB(name: string) { this.currentDB = name; }, + setCurrentPgDB(name: string) { + this.currentPgDB = name; + }, setCurrentRedisDB(name: string) { this.currentRedisDB = name; }, diff --git a/frontend/src/views/database/mysql/index.vue b/frontend/src/views/database/mysql/index.vue index 2a2901092263..58f72efaa5db 100644 --- a/frontend/src/views/database/mysql/index.vue +++ b/frontend/src/views/database/mysql/index.vue @@ -398,6 +398,7 @@ const changeDatabase = async () => { for (const item of dbOptionsLocal.value) { if (item.database == currentDBName.value) { currentDB.value = item; + globalStore.setCurrentDB(currentDB.value.database); appKey.value = item.type; appName.value = item.database; search(); @@ -409,6 +410,7 @@ const changeDatabase = async () => { if (item.database == currentDBName.value) { maskShow.value = false; currentDB.value = item; + globalStore.setCurrentDB(currentDB.value.database); break; } } @@ -532,7 +534,6 @@ const loadDBOptions = async () => { if (currentDB.value?.from === 'remote') { maskShow.value = false; } - globalStore.setCurrentDB(''); search(); return; } diff --git a/frontend/src/views/database/postgresql/index.vue b/frontend/src/views/database/postgresql/index.vue index 0e3e2951d811..f44af0ab8c55 100644 --- a/frontend/src/views/database/postgresql/index.vue +++ b/frontend/src/views/database/postgresql/index.vue @@ -335,7 +335,7 @@ const onChangeConn = async () => { const goRemoteDB = async () => { if (currentDB.value) { - globalStore.setCurrentDB(currentDB.value.database); + globalStore.setCurrentPgDB(currentDB.value.database); } routerToName('PostgreSQL-Remote'); }; @@ -348,7 +348,7 @@ const passwordRef = ref(); const onSetting = async () => { if (currentDB.value) { - globalStore.setCurrentDB(currentDB.value.database); + globalStore.setCurrentPgDB(currentDB.value.database); } routerToNameWithParams('PostgreSQL-Setting', { type: currentDB.value.type, database: currentDB.value.database }); }; @@ -357,6 +357,7 @@ const changeDatabase = async () => { for (const item of dbOptionsLocal.value) { if (item.database == currentDBName.value) { currentDB.value = item; + globalStore.setCurrentPgDB(currentDB.value.database); appKey.value = item.type; appName.value = item.database; search(); @@ -368,6 +369,7 @@ const changeDatabase = async () => { if (item.database == currentDBName.value) { maskShow.value = false; currentDB.value = item; + globalStore.setCurrentPgDB(currentDB.value.database); break; } } @@ -461,7 +463,7 @@ const loadDBOptions = async () => { let datas = res.data || []; dbOptionsLocal.value = []; dbOptionsRemote.value = []; - currentDBName.value = globalStore.currentDB; + currentDBName.value = globalStore.currentPgDB; for (const item of datas) { if (currentDBName.value && item.database === currentDBName.value) { currentDB.value = item; @@ -480,7 +482,6 @@ const loadDBOptions = async () => { if (currentDB.value?.from === 'remote') { maskShow.value = false; } - globalStore.setCurrentDB(''); search(); return; } diff --git a/frontend/src/views/database/redis/index.vue b/frontend/src/views/database/redis/index.vue index dcb908e33851..a61909d42f42 100644 --- a/frontend/src/views/database/redis/index.vue +++ b/frontend/src/views/database/redis/index.vue @@ -226,6 +226,7 @@ const changeDatabase = async () => { for (const item of dbOptionsLocal.value) { if (item.database == currentDBName.value) { currentDB.value = item; + globalStore.setCurrentRedisDB(currentDB.value.database); appKey.value = item.type; appName.value = item.database; appStatusRef.value?.onCheck(appKey.value, appName.value); @@ -236,6 +237,7 @@ const changeDatabase = async () => { for (const item of dbOptionsRemote.value) { if (item.database == currentDBName.value) { currentDB.value = item; + globalStore.setCurrentRedisDB(currentDB.value.database); break; } } @@ -248,7 +250,7 @@ const loadDBOptions = async () => { let datas = res.data || []; dbOptionsLocal.value = []; dbOptionsRemote.value = []; - currentDBName.value = globalStore.currentDB; + currentDBName.value = globalStore.currentRedisDB; for (const item of datas) { if (currentDBName.value && item.database === currentDBName.value) { currentDB.value = item;