mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-15 10:14:44 +08:00
feat: 数据库设置或远程服务器跳转返回时跳转到原路由 (#2207)
This commit is contained in:
parent
02dce0e3fa
commit
add4fab794
@ -276,6 +276,7 @@ type DatabaseCreate struct {
|
|||||||
|
|
||||||
type DatabaseUpdate struct {
|
type DatabaseUpdate struct {
|
||||||
ID uint `json:"id"`
|
ID uint `json:"id"`
|
||||||
|
Type string `json:"type" validate:"required"`
|
||||||
Version string `json:"version" validate:"required"`
|
Version string `json:"version" validate:"required"`
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
Port uint `json:"port"`
|
Port uint `json:"port"`
|
||||||
|
@ -148,6 +148,7 @@ func (u *DatabaseService) Update(req dto.DatabaseUpdate) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
upMap := make(map[string]interface{})
|
upMap := make(map[string]interface{})
|
||||||
|
upMap["type"] = req.Type
|
||||||
upMap["version"] = req.Version
|
upMap["version"] = req.Version
|
||||||
upMap["address"] = req.Address
|
upMap["address"] = req.Address
|
||||||
upMap["port"] = req.Port
|
upMap["port"] = req.Port
|
||||||
|
@ -27,6 +27,7 @@ export const GlobalStore = defineStore({
|
|||||||
ignoreCaptcha: true,
|
ignoreCaptcha: true,
|
||||||
device: DeviceType.Desktop,
|
device: DeviceType.Desktop,
|
||||||
lastFilePath: '',
|
lastFilePath: '',
|
||||||
|
currentDB: '',
|
||||||
}),
|
}),
|
||||||
getters: {},
|
getters: {},
|
||||||
actions: {
|
actions: {
|
||||||
@ -64,6 +65,9 @@ export const GlobalStore = defineStore({
|
|||||||
setLastFilePath(path: string) {
|
setLastFilePath(path: string) {
|
||||||
this.lastFilePath = path;
|
this.lastFilePath = path;
|
||||||
},
|
},
|
||||||
|
setCurrentDB(name: string) {
|
||||||
|
this.currentDB = name;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
persist: piniaPersistConfig('GlobalState'),
|
persist: piniaPersistConfig('GlobalState'),
|
||||||
});
|
});
|
||||||
|
@ -22,6 +22,7 @@ export interface GlobalState {
|
|||||||
ignoreCaptcha: boolean;
|
ignoreCaptcha: boolean;
|
||||||
device: DeviceType;
|
device: DeviceType;
|
||||||
lastFilePath: string;
|
lastFilePath: string;
|
||||||
|
currentDB: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MenuState {
|
export interface MenuState {
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
<el-option
|
<el-option
|
||||||
v-if="item.from === 'local'"
|
v-if="item.from === 'local'"
|
||||||
:value="item.database"
|
:value="item.database"
|
||||||
:label="item.database + ' [' + item.type + ']'"
|
:label="item.database + ' [' + (item.type === 'mysql' ? 'MySQL' : 'MariaDB') + ']'"
|
||||||
></el-option>
|
></el-option>
|
||||||
</div>
|
</div>
|
||||||
<el-button link type="primary" class="jumpAdd" @click="goRouter('app')" icon="Position">
|
<el-button link type="primary" class="jumpAdd" @click="goRouter('app')" icon="Position">
|
||||||
@ -42,7 +42,7 @@
|
|||||||
<el-option
|
<el-option
|
||||||
v-if="item.from === 'remote'"
|
v-if="item.from === 'remote'"
|
||||||
:value="item.database"
|
:value="item.database"
|
||||||
:label="item.database + ' [' + item.type + ']'"
|
:label="item.database + ' [' + (item.type === 'mysql' ? 'MySQL' : 'MariaDB') + ']'"
|
||||||
></el-option>
|
></el-option>
|
||||||
</div>
|
</div>
|
||||||
<el-button link type="primary" class="jumpAdd" @click="goRouter('remote')" icon="Position">
|
<el-button link type="primary" class="jumpAdd" @click="goRouter('remote')" icon="Position">
|
||||||
@ -235,6 +235,8 @@ import router from '@/routers';
|
|||||||
import { MsgError, MsgSuccess } from '@/utils/message';
|
import { MsgError, MsgSuccess } from '@/utils/message';
|
||||||
import useClipboard from 'vue-clipboard3';
|
import useClipboard from 'vue-clipboard3';
|
||||||
const { toClipboard } = useClipboard();
|
const { toClipboard } = useClipboard();
|
||||||
|
import { GlobalStore } from '@/store';
|
||||||
|
const globalStore = GlobalStore();
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const maskShow = ref(true);
|
const maskShow = ref(true);
|
||||||
@ -293,12 +295,14 @@ const onChangeConn = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const goRemoteDB = async () => {
|
const goRemoteDB = async () => {
|
||||||
|
globalStore.setCurrentDB(currentDB.value.database);
|
||||||
router.push({ name: 'MySQL-Remote' });
|
router.push({ name: 'MySQL-Remote' });
|
||||||
};
|
};
|
||||||
|
|
||||||
const passwordRef = ref();
|
const passwordRef = ref();
|
||||||
|
|
||||||
const onSetting = async () => {
|
const onSetting = async () => {
|
||||||
|
globalStore.setCurrentDB(currentDB.value.database);
|
||||||
router.push({ name: 'MySQL-Setting', params: { type: currentDB.value.type, database: currentDB.value.database } });
|
router.push({ name: 'MySQL-Setting', params: { type: currentDB.value.type, database: currentDB.value.database } });
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -401,13 +405,26 @@ const loadDBOptions = async () => {
|
|||||||
let datas = res.data || [];
|
let datas = res.data || [];
|
||||||
dbOptionsLocal.value = [];
|
dbOptionsLocal.value = [];
|
||||||
dbOptionsRemote.value = [];
|
dbOptionsRemote.value = [];
|
||||||
|
currentDBName.value = globalStore.currentDB;
|
||||||
for (const item of datas) {
|
for (const item of datas) {
|
||||||
|
if (currentDBName.value && item.database === currentDBName.value) {
|
||||||
|
currentDB.value = item;
|
||||||
|
if (item.from === 'local') {
|
||||||
|
appKey.value = item.type;
|
||||||
|
appName.value = item.database;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (item.from === 'local') {
|
if (item.from === 'local') {
|
||||||
dbOptionsLocal.value.push(item);
|
dbOptionsLocal.value.push(item);
|
||||||
} else {
|
} else {
|
||||||
dbOptionsRemote.value.push(item);
|
dbOptionsRemote.value.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (currentDB.value) {
|
||||||
|
globalStore.setCurrentDB('');
|
||||||
|
search();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (dbOptionsLocal.value.length !== 0) {
|
if (dbOptionsLocal.value.length !== 0) {
|
||||||
currentDB.value = dbOptionsLocal.value[0];
|
currentDB.value = dbOptionsLocal.value[0];
|
||||||
currentDBName.value = dbOptionsLocal.value[0].database;
|
currentDBName.value = dbOptionsLocal.value[0].database;
|
||||||
|
@ -99,6 +99,18 @@ const loading = ref();
|
|||||||
|
|
||||||
const acceptParams = (params: DialogProps): void => {
|
const acceptParams = (params: DialogProps): void => {
|
||||||
dialogData.value = params;
|
dialogData.value = params;
|
||||||
|
if (dialogData.value.rowData.version.startsWith('5.6')) {
|
||||||
|
dialogData.value.rowData.version = '5.6';
|
||||||
|
}
|
||||||
|
if (dialogData.value.rowData.version.startsWith('5.7')) {
|
||||||
|
dialogData.value.rowData.version = '5.7';
|
||||||
|
}
|
||||||
|
if (dialogData.value.rowData.version.startsWith('8.')) {
|
||||||
|
dialogData.value.rowData.version = '8.x';
|
||||||
|
}
|
||||||
|
if (dialogData.value.rowData.version.startsWith('10.')) {
|
||||||
|
dialogData.value.rowData.version = '10.x';
|
||||||
|
}
|
||||||
title.value = i18n.global.t('database.' + dialogData.value.title + 'RemoteDB');
|
title.value = i18n.global.t('database.' + dialogData.value.title + 'RemoteDB');
|
||||||
drawerVisiable.value = true;
|
drawerVisiable.value = true;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user