sql执行器页面刷新记住数据库,可同时存在多个数据库执行器页面

This commit is contained in:
diant
2023-05-23 14:00:00 +08:00
parent a02aa870ae
commit 960eccd165
8 changed files with 78 additions and 20 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon-db.png"><title>数据库文档管理</title><link href="css/chunk-vendors.2fa4c9b3.css" rel="preload" as="style"><link href="css/index.7acc9f77.css" rel="preload" as="style"><link href="js/chunk-vendors.efca7909.js" rel="preload" as="script"><link href="js/index.ccb56003.js" rel="preload" as="script"><link href="css/chunk-vendors.2fa4c9b3.css" rel="stylesheet"><link href="css/index.7acc9f77.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but zyplayer-db-ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.efca7909.js"></script><script src="js/index.ccb56003.js"></script></body></html>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon-db.png"><title>数据库文档管理</title><link href="css/chunk-vendors.2fa4c9b3.css" rel="preload" as="style"><link href="css/index.108f40b4.css" rel="preload" as="style"><link href="js/chunk-vendors.6270548d.js" rel="preload" as="script"><link href="js/index.ddad9e6e.js" rel="preload" as="script"><link href="css/chunk-vendors.2fa4c9b3.css" rel="stylesheet"><link href="css/index.108f40b4.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but zyplayer-db-ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.6270548d.js"></script><script src="js/index.ddad9e6e.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -43,7 +43,7 @@
let dataname = json.data.name;
let groupName = json.data.name;
if(dataname){
name = name+"("+dataname+")"
name = name+"( "+dataname+"["+database+"] )"
}
this.pageList.push({name, path, fullPath});
let activePage = this.getRouteRealPath(this.$route);
@@ -52,6 +52,28 @@
this.$router.push(this.$route.fullPath);
})
return false;
}else{
datasourceApi.datasourceList({}).then(json => {
this.datasourceList = json.data || [];
if (this.datasourceList.length > 0) {
let dataname = this.datasourceList[0].name;
if(this.datasourceList[0].id){
datasourceApi.databaseList({sourceId: this.datasourceList[0].id}).then(json => {
if (json.data.length > 0) {
// 排除系统库
let sysDbName = ["information_schema", "master", "model", "msdb", "tempdb"];
let notSysDbItem = json.data.find(item => sysDbName.indexOf(item.dbName) < 0);
let choiceDatabase = (!!notSysDbItem) ? notSysDbItem.dbName : json.data[0].dbName;
if(dataname&&choiceDatabase){
name = name+"( "+dataname+"["+choiceDatabase+"] )"
}
this.$router.replace({ query: { datasourceId: this.datasourceList[0].id,database:choiceDatabase } })
}
})
}
}
})
return false;
}
}
this.pageList.push({name, path, fullPath});
@@ -67,7 +89,7 @@
if (this.linkList.indexOf(activePage) < 0) {
this.linkList.push(activePage);
let {name, path, fullPath} = newRoute;
this.pageList.push({name, path, fullPath});
//sql执行器tab页名称动态变化
if(path === '/data/executor'){
let database = newRoute.query.database;
@@ -75,22 +97,46 @@
if(datasourceId) {
datasourceApi.datasource({sourceId: datasourceId}).then(json => {
let dataname = json.data.name;
let groupName = json.data.name;
let groupName = json.data.groupName;
if (dataname) {
name = name + "(" + dataname + ")"
name = name+"( "+dataname+"["+database+"] )"
}
this.pageList.push({name, path, fullPath});
//this.pageList.push({name, path, fullPath});
let pageRoute = this.pageList.find(item => this.getRouteRealPath(item) === activePage);
pageRoute.name = name;
})
}else{
this.pageList.push({name, path, fullPath});
datasourceApi.datasourceList({}).then(json => {
this.datasourceList = json.data || [];
if (this.datasourceList.length > 0) {
let dataname = this.datasourceList[0].name;
if(this.datasourceList[0].id){
datasourceApi.databaseList({sourceId: this.datasourceList[0].id}).then(json => {
if (json.data.length > 0) {
// 排除系统库
let sysDbName = ["information_schema", "master", "model", "msdb", "tempdb"];
let notSysDbItem = json.data.find(item => sysDbName.indexOf(item.dbName) < 0);
let choiceDatabase = (!!notSysDbItem) ? notSysDbItem.dbName : json.data[0].dbName;
if(dataname&&choiceDatabase){
name = name+"( "+dataname+"["+choiceDatabase+"] )"
}
console.log("this.pageList+++++++++"+JSON.stringify(this.pageList))
this.pageList.splice(this.pageList.findIndex(item => item.fullPath === path),1);
this.linkList.splice(this.linkList.findIndex(item => item === path),1);
console.log("this.pageList+++++++++"+JSON.stringify(this.pageList))
this.$router.replace({ query: { datasourceId: this.datasourceList[0].id,database:choiceDatabase } })
}
})
}
}
})
}
}else{
this.pageList.push({name, path, fullPath});
}
}
let pageRoute = this.pageList.find(item => this.getRouteRealPath(item) === activePage);
pageRoute.fullPath = newRoute.fullPath;
//let pageRoute = this.pageList.find(item => this.getRouteRealPath(item) === activePage);
//pageRoute.fullPath = newRoute.fullPath;
},
},
methods: {
@@ -143,4 +189,12 @@
height: 30px;
line-height: 30px;
}
/deep/ .el-tabs__nav-next{
line-height: 33px;
font-size: 20px;
}
/deep/ .el-tabs__nav-prev{
line-height: 33px;
font-size: 20px;
}
</style>

View File

@@ -365,6 +365,10 @@ export default {
this.$message.error("请先选择数据源");
return;
}
if(!this.choiceDatabase){
this.$message.error("请先选择数据库");
return;
}
this.executeError = "";
this.executeUseTime = "";
this.executeResultList = [];
@@ -612,13 +616,12 @@ export default {
// 排除系统库
let sysDbName = ["information_schema", "master", "model", "msdb", "tempdb"];
let notSysDbItem = this.databaseList.find(item => sysDbName.indexOf(item.dbName) < 0);
this.choiceDatabase = (!!notSysDbItem) ? notSysDbItem.dbName : this.databaseList[0].dbName;
this.executorSource = {sourceId: this.choiceDatasourceId, dbName: this.choiceDatabase};
// 非初次加载动态改变url参数
// 非初次加载动态改变url参数
if(!initFlag){
this.choiceDatabase = (!!notSysDbItem) ? notSysDbItem.dbName : this.databaseList[0].dbName;
this.$router.replace({ query: { datasourceId: this.choiceDatasourceId,database:this.choiceDatabase } })
}
}
this.executorSource = {sourceId: this.choiceDatasourceId, dbName: this.choiceDatabase};
}
});
},
@@ -653,6 +656,7 @@ export default {
this.loadHistoryAndFavoriteList();
},
databaseChangeEvents() {
this.$router.replace({ query: { datasourceId: this.choiceDatasourceId,database:this.choiceDatabase } })
this.executorSource = {sourceId: this.choiceDatasourceId, dbName: this.choiceDatabase};
this.currentPage = 1;
},