mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-09-23 00:00:52 +00:00
@@ -44,6 +44,7 @@ export interface GlobalState {
|
||||
device: DeviceType;
|
||||
lastFilePath: string;
|
||||
currentDB: string;
|
||||
currentPgDB: string;
|
||||
currentRedisDB: string;
|
||||
showEntranceWarn: boolean;
|
||||
defaultNetwork: string;
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user