Files
zyplayer-doc/zyplayer-doc-ui/db-ui/src/App.vue

368 lines
17 KiB
Vue
Raw Normal View History

2019-07-04 21:52:39 +08:00
<template>
<div id="app">
<template v-if="fullscreen">
2019-07-04 21:52:39 +08:00
<router-view></router-view>
</template>
<el-container v-else>
<el-aside style="background: #fafafa;">
<div style="padding: 10px;height: 100%;box-sizing: border-box;">
2019-07-04 21:52:39 +08:00
<div style="margin-bottom: 10px;">
2020-05-24 13:00:43 +08:00
<el-select v-model="choiceDatasourceGroup" @change="sourceGroupChangeEvents" size="small" filterable placeholder="请先选择分组" style="width: 100%;">
<el-option value="" label="全部分组"></el-option>
<el-option v-for="item in datasourceGroupList" :key="item" :value="item"></el-option>
</el-select>
2020-05-24 13:00:43 +08:00
<el-select v-model="choiceDatasourceId" @change="datasourceChangeEvents" size="small" filterable placeholder="请先选择数据源" style="width: 100%;margin-top: 10px;">
2019-07-04 21:52:39 +08:00
<el-option v-for="item in datasourceOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select>
</div>
<el-menu :router="true" class="el-menu-vertical" style="height: auto;">
<el-menu-item index="/data/datasourceManage"><i class="el-icon-coin"></i>数据源管理</el-menu-item>
<el-menu-item index="/data/executor"><i class="el-icon-video-play"></i>SQL执行器</el-menu-item>
2019-10-06 18:19:27 +08:00
<el-submenu index="1">
<template slot="title">
<i class="el-icon-s-platform"></i>
<span slot="title">管理工具</span>
</template>
<el-menu-item index="/data/export"><i class="el-icon-finished"></i>数据库表导出</el-menu-item>
<el-menu-item index="/data/transferData"><i class="el-icon-document-copy"></i>数据互导工具</el-menu-item>
</el-submenu>
2019-07-04 21:52:39 +08:00
</el-menu>
2021-01-23 13:30:27 +08:00
<el-tree :props="defaultProps" :data="databaseList" @node-click="handleNodeClick"
ref="databaseTree" highlight-current empty-text=""
:default-expanded-keys="databaseExpandedKeys"
node-key="id" @node-expand="handleNodeExpand"
class="database-list-tree" style="overflow-x: auto;">
<div slot-scope="{node, data}">
<span v-if="data.needLoad"><i class="el-icon-loading"></i></span>
<span v-else>
{{node.label}}
<el-tooltip v-if="!!data.comment" effect="dark" :content="data.comment" placement="top-start" :open-delay="600">
<span style="color: #aaa;">-{{data.comment}}</span>
</el-tooltip>
<el-dropdown v-if="data.type == 1" @command="databaseActionDropdown">
<i class="el-icon-more" @click.stop=""></i>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item icon="el-icon-coin" :command="{command: 'procedure', node: node}">函数管理</el-dropdown-item>
2021-01-23 13:30:27 +08:00
<el-dropdown-item icon="el-icon-refresh" :command="{command: 'refresh', node: node}">刷新</el-dropdown-item>
<!-- <el-dropdown-item icon="el-icon-upload2" :command="{command: 'upload', node: node}">导入</el-dropdown-item>-->
<!-- <el-dropdown-item icon="el-icon-download" :command="{command: 'download', node: node}">导出</el-dropdown-item>-->
</el-dropdown-menu>
</el-dropdown>
</span>
</div>
</el-tree>
2019-07-04 21:52:39 +08:00
</div>
</el-aside>
<el-container>
<el-header>
<span class="header-right-user-name">{{userSelfInfo.userName}}</span>
<el-dropdown @command="userSettingDropdown" trigger="click">
<i class="el-icon-setting" style="margin-right: 15px; font-size: 16px;cursor: pointer;color: #fff;"> </i>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="console">控制台</el-dropdown-item>
<el-dropdown-item command="aboutDoc" divided>关于</el-dropdown-item>
<el-dropdown-item command="myInfo">我的资料</el-dropdown-item>
<el-dropdown-item command="userSignOut">退出登录</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-header>
<el-main style="padding: 0;">
<router-view @initLoadDataList="initLoadDataList"
@loadDatasourceList="loadDatasourceList">
</router-view>
</el-main>
</el-container>
2019-07-04 21:52:39 +08:00
</el-container>
<!--关于弹窗-->
2021-07-08 23:10:47 +08:00
<el-dialog title="关于" :visible.sync="aboutDialogVisible" width="600px" custom-class="about-zyplayer-doc">
<div style="">
<div style="font-weight: bold;font-size: 25px;">zyplayer-doc</div>
<div style="line-height: 30px;font-size: 12px;color: #666;padding: 10px 0;">
<div>版本 {{upgradeInfo.nowVersion || '1.0.9'}}</div>
<div>版权所有 © 2018-2021 <a target="_blank" href="http://doc.zyplayer.com">doc.zyplayer.com</a></div>
</div>
<template v-if="!!upgradeInfo.nowVersion">v{{upgradeInfo.nowVersion}}</template>
<el-tabs type="border-card">
<el-tab-pane label="支持">
<div style="line-height: 30px;">
<div>文档<a target="_blank" href="http://doc.zyplayer.com/zyplayer-doc-manage/doc-wiki#/page/share/view?pageId=1&space=23f3f59a60824d21af9f7c3bbc9bc3cb">http://doc.zyplayer.com</a></div>
<div>主页<a target="_blank" href="https://gitee.com/zyplayer/zyplayer-doc">https://gitee.com/zyplayer/zyplayer-doc</a></div>
<div>反馈<a target="_blank" href="https://gitee.com/zyplayer/zyplayer-doc/issues">https://gitee.com/zyplayer/zyplayer-doc/issues</a></div>
<div>特性关注&技术交流QQ群466363173</div>
<el-divider content-position="left">UI/设计/开发/测试</el-divider>
<div><a target="_blank" href="http://zyplayer.com">暮光城中城</a></div>
<el-divider content-position="left">参与人员</el-divider>
<div>
辽宁-天平
</div>
</div>
</el-tab-pane>
<el-tab-pane label="开源软件">
<div style="line-height: 30px;">
<div>此项目基于以下开源软件构建</div>
<el-divider content-position="left">后端</el-divider>
<div>
<a target="_blank" href="https://spring.io/projects/spring-boot">Spring-Boot</a>
<a target="_blank" href="http://www.mybatis.org">MyBatis</a>
<a target="_blank" href="https://github.com/alibaba/druid">Druid</a>
<a target="_blank" href="https://mp.baomidou.com">MyBatis-Plus</a>
<a target="_blank" href="https://www.hutool.cn">Hutool</a>
<a target="_blank" href="https://github.com/alibaba/fastjson">Fastjson</a>
<a target="_blank" href="https://alibaba-easyexcel.github.io">Easy Excel</a>
<a target="_blank" href="https://swagger.io">Swagger</a>
<a target="_blank" href="https://dubbo.io">Dubbo</a>
<a target="_blank" href="http://www.eclipse.org/jgit">JGit</a>...
</div>
<el-divider content-position="left">前端</el-divider>
<div>
</div>
</div>
</el-tab-pane>
<!-- <el-tab-pane label="软件更新" v-if="upgradeInfo.lastVersion">-->
<el-tab-pane>
<span slot="label">
软件更新
<!-- <sup class="el-badge__content el-badge__content&#45;&#45;undefined is-fixed" style="top: 10px;">new</sup>-->
<sup class="el-badge__content el-badge__content--undefined is-fixed is-dot" style="top: 10px;right: 20px;"></sup>
</span>
<div style="line-height: 30px;">
<div>当前版本{{upgradeInfo.nowVersion}}</div>
<div>最新版本{{upgradeInfo.lastVersion}}</div>
<div>升级地址<a target="_blank" :href="upgradeInfo.upgradeUrl">{{upgradeInfo.upgradeUrl}}</a></div>
<div>升级内容{{upgradeInfo.upgradeContent}}</div>
</div>
</el-tab-pane>
</el-tabs>
</div>
2019-07-04 21:52:39 +08:00
</el-dialog>
</div>
</template>
<script>
import userApi from './common/api/user'
import datasourceApi from './common/api/datasource'
2019-07-04 21:52:39 +08:00
export default {
data() {
return {
isCollapse: false,
aboutDialogVisible: false,
userSelfInfo: {},
// 数据源相关
datasourceOptions: [],
datasourceList: [],
datasourceGroupList: [],
2019-08-21 20:39:43 +08:00
choiceDatasourceId: "",
choiceDatasourceGroup: "",
2019-07-04 21:52:39 +08:00
defaultProps: {children: 'children', label: 'name'},
// 页面展示相关
nowDatasourceShow: {},
databaseList: [],
databaseExpandedKeys: [],
// 升级信息
upgradeInfo: {},
}
},
computed: {
fullscreen () {
return this.$store.state.global.fullscreen;
}
},
2019-07-04 21:52:39 +08:00
mounted: function () {
this.getSelfUserInfo();
this.checkSystemUpgrade();
this.loadDatasourceList();
},
methods: {
userSettingDropdown(command) {
console.log("command:" + command);
if (command == 'userSignOut') {
this.userSignOut();
} else if (command == 'aboutDoc') {
this.aboutDialogVisible = true;
2019-07-04 21:52:39 +08:00
} else if (command == 'myInfo') {
this.$router.push({path: '/user/myInfo'});
} else if (command == 'console') {
window.location = process.env.VUE_APP_BASE_API;
2019-07-04 21:52:39 +08:00
} else {
2020-05-24 13:00:43 +08:00
this.$message.warning("功能暂未开放");
2019-07-04 21:52:39 +08:00
}
},
userSignOut() {
userApi.userLogout().then(() => {
2019-07-04 21:52:39 +08:00
location.reload();
});
},
getSelfUserInfo() {
userApi.getSelfUserInfo().then(json=>{
this.userSelfInfo = json.data;
2019-07-04 21:52:39 +08:00
});
},
sourceGroupChangeEvents() {
let datasourceOptions = [];
for (let i = 0; i < this.datasourceList.length; i++) {
let item = this.datasourceList[i];
if (!this.choiceDatasourceGroup || this.choiceDatasourceGroup == item.groupName) {
datasourceOptions.push({label: item.name, value: item.id});
}
}
this.datasourceOptions = datasourceOptions;
this.choiceDatasourceId = '';
this.databaseList = [];
2019-07-04 21:52:39 +08:00
},
datasourceChangeEvents() {
this.nowDatasourceShow = this.choiceDatasourceId;
2019-08-21 20:39:43 +08:00
var host = "";
for (var i = 0; i < this.datasourceList.length; i++) {
if (this.datasourceList[i].id == this.choiceDatasourceId) {
host = this.datasourceList[i].name;
2019-08-21 20:39:43 +08:00
break;
}
}
this.loadDatabaseList(this.choiceDatasourceId, host);
2019-07-04 21:52:39 +08:00
},
handleNodeClick(node) {
console.log("点击节点:", node);
// 执行器里面点击库表不跳转页面
// if (this.$router.currentRoute.path == "/data/executor") {
// return;
// }
2019-07-04 21:52:39 +08:00
if (node.type == 1) {
2019-08-21 20:39:43 +08:00
this.nowClickPath = {sourceId: this.choiceDatasourceId, host: node.host, dbName: node.dbName, tableName: node.tableName};
2019-07-04 21:52:39 +08:00
this.$router.push({path: '/table/database', query: this.nowClickPath});
} else if (node.type == 2) {
2019-08-21 20:39:43 +08:00
this.nowClickPath = {sourceId: this.choiceDatasourceId, host: node.host, dbName: node.dbName, tableName: node.tableName};
2019-07-04 21:52:39 +08:00
this.$router.push({path: '/table/info', query: this.nowClickPath});
}
},
handleNodeExpand(node) {
if (node.children.length > 0 && node.children[0].needLoad) {
console.log("加载节点:", node);
if (node.type == 1) {
this.loadGetTableList(node);
2019-07-04 21:52:39 +08:00
}
}
},
2021-01-23 13:30:27 +08:00
databaseActionDropdown(param) {
if (param.command == 'refresh') {
param.node.loading = true;
param.node.data.children = [];
this.loadGetTableList(param.node.data, () => {
setTimeout(() => param.node.loading = false, 500);
});
} else if (param.command == 'procedure') {
let nodeData = param.node.data;
let procedureParam = {sourceId: this.choiceDatasourceId,dbName: nodeData.dbName, host: nodeData.host};
this.$router.push({path: '/procedure/list', query: procedureParam});
2021-01-23 13:30:27 +08:00
} else {
this.$message.warning("暂未支持的选项");
}
},
2019-07-04 21:52:39 +08:00
loadGetTableList(node, callback) {
datasourceApi.tableList({sourceId: this.choiceDatasourceId, dbName: node.dbName}).then(json => {
let pathIndex = [];
let result = json.data || [];
for (let i = 0; i < result.length; i++) {
let item = {
2019-07-04 21:52:39 +08:00
id: node.host + "_" + node.dbName + "_" + result[i].tableName, host: node.host,
dbName: node.dbName, tableName: result[i].tableName, name: result[i].tableName, type: 2,
comment: result[i].tableComment
2019-07-04 21:52:39 +08:00
};
// item.children = [{label: '', needLoad: true}];// 初始化一个对象,点击展开时重新查询加载
pathIndex.push(item);
}
node.children = pathIndex;
if (typeof callback == 'function') {
callback(pathIndex);
}
});
},
loadDatasourceList() {
datasourceApi.datasourceList({}).then(json => {
this.datasourceList = json.data || [];
let datasourceOptions = [];
for (let i = 0; i < this.datasourceList.length; i++) {
let item = this.datasourceList[i];
datasourceOptions.push({label: item.name, value: item.id});
}
this.datasourceOptions = datasourceOptions;
let datasourceGroupList = [];
this.datasourceList.filter(item => !!item.groupName).forEach(item => datasourceGroupList.push(item.groupName || ''));
this.datasourceGroupList = Array.from(new Set(datasourceGroupList));
});
2019-07-04 21:52:39 +08:00
},
loadDatabaseList(sourceId, host) {
return new Promise((resolve, reject) => {
this.databaseList = [];
datasourceApi.databaseList({sourceId: sourceId}).then(json => {
let result = json.data || [];
let pathIndex = [];
let children = [];
for (let i = 0; i < result.length; i++) {
let item = {
id: host + "_" + result[i].dbName, host: host, dbName: result[i].dbName,
name: result[i].dbName, type: 1
};
item.children = [{label: '', needLoad: true}];// 初始化一个对象,点击展开时重新查询加载
children.push(item);
}
pathIndex.push({id: host, host: host, name: host, children: children});
this.databaseList = pathIndex;
resolve();
});
});
2019-07-04 21:52:39 +08:00
},
initLoadDataList(param) {
if (this.databaseList.length > 0) {
2019-07-04 21:52:39 +08:00
return;
}
this.choiceDatasourceId = parseInt(param.sourceId);
this.loadDatabaseList(param.sourceId, param.host).then(() => {
this.databaseExpandedKeys = [param.host];
});
2019-07-04 21:52:39 +08:00
},
checkSystemUpgrade() {
datasourceApi.systemUpgradeInfo({}).then(json => {
2019-07-04 21:52:39 +08:00
if (!!json.data) {
this.upgradeInfo = json.data;
2019-07-04 21:52:39 +08:00
console.log("zyplayer-doc发现新版本"
+ "\n升级地址" + json.data.upgradeUrl
+ "\n当前版本" + json.data.nowVersion
+ "\n最新版本" + json.data.lastVersion
+ "\n升级内容" + json.data.upgradeContent
);
}
});
},
}
}
</script>
<style>
html, body {
margin: 0;
padding: 0;
height: 100%;
}
#app, .el-container, .el-menu {
height: 100%;
}
2020-05-24 13:00:43 +08:00
.el-header {
background-color: #1D4E89 !important;
}
.database-list-tree{background-color: #fafafa;}
.database-list-tree .el-tree-node>.el-tree-node__children {
overflow: unset;
}
2019-07-04 21:52:39 +08:00
.header-right-user-name{color: #fff;padding-right: 5px;}
.el-menu-vertical{border-right: 0;background: #fafafa;}
.el-menu-vertical .el-menu{background: #fafafa;}
.el-header {background-color: #409EFF; color: #333; line-height: 40px; text-align: right;height: 40px !important;}
2021-01-23 13:30:27 +08:00
.el-tree-node__content{}
.el-tree-node__content .el-icon-more{margin-left: 5px;color: #606266;font-size: 12px; display: none;padding: 2px 5px;}
.el-tree-node__content:hover .el-icon-more{display: inline-block;}
2021-07-08 23:10:47 +08:00
.about-zyplayer-doc .el-dialog__body{padding: 20px;}
2019-07-04 21:52:39 +08:00
</style>