2021-10-17 19:50:22 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="menu-layout">
|
2021-10-20 22:32:25 +08:00
|
|
|
<div style="padding: 10px 5px;">
|
|
|
|
|
<a-select placeholder="请选择分组" v-model:value="swaggerDocChoice" style="width: 100%;">
|
|
|
|
|
<a-select-option :value="item.url" v-for="item in swaggerResourceList">{{item.name}}</a-select-option>
|
|
|
|
|
</a-select>
|
|
|
|
|
</div>
|
2021-10-17 19:50:22 +08:00
|
|
|
<a-menu theme="light" mode="inline" :inline-collapsed="collapsed" v-model:openKeys="openKeys" v-model:selectedKeys="selectedKeys">
|
|
|
|
|
<menu-children-layout :menuItem="menuItem" v-for="menuItem in menuData"></menu-children-layout>
|
|
|
|
|
</a-menu>
|
2021-10-20 22:32:25 +08:00
|
|
|
<a-directory-tree :tree-data="treeData" v-model:expandedKeys="expandedKeys" @select="docChecked"></a-directory-tree>
|
2021-10-17 19:50:22 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import MenuChildrenLayout from './MenuChildrenLayout.vue'
|
2021-10-20 22:32:25 +08:00
|
|
|
import {customApi} from '../../api'
|
2021-10-17 19:50:22 +08:00
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'MenuLayout',
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
menuData: [],
|
|
|
|
|
selectedKeys: [],
|
|
|
|
|
openKeys: [],
|
|
|
|
|
collapsed: false,
|
|
|
|
|
// 文档树
|
|
|
|
|
treeData: [
|
|
|
|
|
{
|
|
|
|
|
title: '用户管理接口文档',
|
|
|
|
|
key: '0-0',
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
title: '用户信息管理',
|
|
|
|
|
key: '0-0-0',
|
|
|
|
|
children: [
|
|
|
|
|
{title: '/getUserInfo', key: '0-0-0-0', isLeaf: true, path: '/doc/view', query: {path: '/getUserInfo'}},
|
|
|
|
|
{title: '/deleteUserInfo', key: '0-0-0-1', isLeaf: true, path: '/doc/view', query: {path: '/deleteUserInfo'}},
|
|
|
|
|
{title: '/updateUserInfo', key: '0-0-0-2', isLeaf: true, path: '/doc/view', query: {path: '/updateUserInfo'}},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
expandedKeys: [],
|
2021-10-20 22:32:25 +08:00
|
|
|
swaggerResourceList: [],
|
|
|
|
|
swaggerDocChoice: undefined,
|
2021-10-17 19:50:22 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
watch:{
|
|
|
|
|
'$store.state.userInfo'(userInfo) {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
components: {MenuChildrenLayout},
|
|
|
|
|
mounted() {
|
2021-10-20 22:32:25 +08:00
|
|
|
this.menuData = this.$router.options.routes.find((item) => item.path === '/').children[0].children;
|
2021-10-17 19:50:22 +08:00
|
|
|
let meta = this.$route.meta || {};
|
|
|
|
|
let path = this.$route.path;
|
|
|
|
|
if (!!meta.parentPath) {
|
|
|
|
|
path = meta.parentPath;
|
|
|
|
|
}
|
|
|
|
|
this.selectedKeys = [path];
|
|
|
|
|
let matched = this.$route.matched;
|
|
|
|
|
if (matched.length >= 1) {
|
|
|
|
|
this.openKeys = [matched[1].path];
|
|
|
|
|
}
|
2021-10-20 22:32:25 +08:00
|
|
|
this.getSwaggerResourceList();
|
2021-10-17 19:50:22 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
docChecked(val, node) {
|
|
|
|
|
if (node.node.isLeaf) {
|
|
|
|
|
let dataRef = node.node.dataRef;
|
|
|
|
|
this.$router.push({path: dataRef.path, query: dataRef.query});
|
|
|
|
|
}
|
2021-10-20 22:32:25 +08:00
|
|
|
},
|
|
|
|
|
getSwaggerResourceList() {
|
|
|
|
|
customApi.post('./swagger-resources').then(res => {
|
|
|
|
|
this.swaggerResourceList = res || [];
|
|
|
|
|
if (this.swaggerResourceList.length > 0) {
|
|
|
|
|
this.swaggerDocChoice = this.swaggerResourceList[0].url;
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-10-17 19:50:22 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|