Browse Source

修改, 增加菜单栏显示子目录的时候父目录也可以显示数据

master
wen 2 years ago
parent
commit
6e4d1a4ad1
  1. 43
      src/layout/components/Sidebar/SidebarItem.vue
  2. 3
      src/layout/components/Sidebar/index.vue
  3. 3
      src/layout/components/Sidebar/leftMenusData.js

43
src/layout/components/Sidebar/SidebarItem.vue

@ -10,19 +10,36 @@ @@ -10,19 +10,36 @@
</app-link>
</template>
<el-submenu v-else ref="subMenu" :index="resolvePath(item.path)" popper-append-to-body>
<template slot="title">
<item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="item.meta.title" />
</template>
<sidebar-item
v-for="child in item.children"
:key="child.path"
:is-nest="true"
:item="child"
:base-path="resolvePath(child.path)"
class="nest-menu"
/>
</el-submenu>
<template v-else>
<a v-if="item.class && item.class == 'file'" :href="'#'+resolvePath(item.path)" >
<el-submenu ref="subMenu" :index="resolvePath(item.path)" popper-append-to-body>
<template slot="title">
<item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="item.meta.title" />
</template>
<sidebar-item
v-for="child in item.children"
:key="child.path"
:is-nest="true"
:item="child"
:base-path="resolvePath(child.path)"
class="nest-menu"
/>
</el-submenu>
</a>
<el-submenu v-else ref="subMenu" :index="resolvePath(item.path)" popper-append-to-body>
<template slot="title">
<item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="item.meta.title" />
</template>
<sidebar-item
v-for="child in item.children"
:key="child.path"
:is-nest="true"
:item="child"
:base-path="resolvePath(child.path)"
class="nest-menu"
/>
</el-submenu>
</template >
</div>
</template>

3
src/layout/components/Sidebar/index.vue

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
<logo v-if="showLogo" :collapse="isCollapse" />
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-menu
:router="true"
:default-active="activeMenu"
:collapse="isCollapse"
:background-color="variables.menuBg"
@ -90,6 +91,7 @@ export default { @@ -90,6 +91,7 @@ export default {
newMenu = {
path: '/subfile?id='+item.id,
meta: { title: item.directory, icon: 'dashboard' },
class: 'file',
children:[]
}
if (item.directories && item.directories.length > 0) {
@ -105,6 +107,7 @@ export default { @@ -105,6 +107,7 @@ export default {
let thiss = this;
//console.log(this.$route);
// console.log(this.$store);
mirlist().then(response => {
let datamain = response.data;
this.routes[1].children = this.SplicingMenuTree(datamain.data.menus);

3
src/layout/components/Sidebar/leftMenusData.js

@ -35,8 +35,9 @@ var menusdata = [ @@ -35,8 +35,9 @@ var menusdata = [
},
{
id: '0',
id: '1',
path: '/filemange',
class: 'file',
meta: { title: '文件管理', icon: 'dashboard' },
children:[]
},

Loading…
Cancel
Save