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