Browse Source

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

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

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

@ -10,6 +10,22 @@
</app-link> </app-link>
</template> </template>
<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> <el-submenu v-else ref="subMenu" :index="resolvePath(item.path)" popper-append-to-body>
<template slot="title"> <template slot="title">
<item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="item.meta.title" /> <item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="item.meta.title" />
@ -23,6 +39,7 @@
class="nest-menu" class="nest-menu"
/> />
</el-submenu> </el-submenu>
</template >
</div> </div>
</template> </template>

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

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

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

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

Loading…
Cancel
Save