|
|
|
@ -29,12 +29,11 @@ import menusdata from './leftMenusData.js'
@@ -29,12 +29,11 @@ import menusdata from './leftMenusData.js'
|
|
|
|
|
import { mirlist } from '@/api/user' |
|
|
|
|
|
|
|
|
|
//console.log(menusdata); |
|
|
|
|
var dfdg = 10; |
|
|
|
|
export default { |
|
|
|
|
components: { SidebarItem, Logo }, |
|
|
|
|
created: function () { |
|
|
|
|
this.getmunusdata(); |
|
|
|
|
//this.menusdatas = '' |
|
|
|
|
var fe = 10; |
|
|
|
|
}, |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
@ -48,12 +47,23 @@ export default {
@@ -48,12 +47,23 @@ export default {
|
|
|
|
|
// routes() { |
|
|
|
|
// return this.$router.options.routes |
|
|
|
|
// }, |
|
|
|
|
|
|
|
|
|
// 获取当前激活菜单的index,默认选中的菜单 |
|
|
|
|
activeMenu() { |
|
|
|
|
const route = this.$route |
|
|
|
|
const { meta, path } = route |
|
|
|
|
const menusindex = window.location.href |
|
|
|
|
|
|
|
|
|
// 因为菜单栏的生成和路由是解耦的,因为动态获取以及添加的菜单都是用的同一个path带不同参数,路由没法获取,所以通过获取地址来选中 |
|
|
|
|
let getcan = menusindex.split('?id'); |
|
|
|
|
if (getcan[1]) { |
|
|
|
|
//console.log(menusindex.split('/#')); |
|
|
|
|
return menusindex.split('/#')[1] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// if set path, the sidebar will highlight the path you set |
|
|
|
|
if (meta.activeMenu) { |
|
|
|
|
return meta.activeMenu |
|
|
|
|
return meta.activeMenu //当前激活的菜单 |
|
|
|
|
} |
|
|
|
|
return path |
|
|
|
|
}, |
|
|
|
@ -77,39 +87,29 @@ export default {
@@ -77,39 +87,29 @@ export default {
|
|
|
|
|
// this.$set(this.menusdata,'children', []) |
|
|
|
|
// //menusdata[0].children = [] |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
newMenu = { |
|
|
|
|
path: '/subfile?id='+item.id, |
|
|
|
|
meta: { title: item.directory, icon: 'dashboard' }, |
|
|
|
|
path: '/filemange/subfile?id='+item.id, |
|
|
|
|
meta: { title: item.directory, activeMenu:'subfile?id='+item.id, icon: 'dashboard' }, |
|
|
|
|
children:[] |
|
|
|
|
} |
|
|
|
|
//console.log(item.directories.length); |
|
|
|
|
if (item.directories && item.directories.length > 0) { |
|
|
|
|
newMenu.children = this.SplicingMenuTree(item.directories,) |
|
|
|
|
newMenu.children = this.SplicingMenuTree(item.directories) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
arrMenus.push(newMenu); |
|
|
|
|
//console.log(arrMenus); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
return arrMenus; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
getmunusdata() { |
|
|
|
|
let thiss = this; |
|
|
|
|
// console.log(this.$route); |
|
|
|
|
//console.log(this.$route); |
|
|
|
|
// console.log(this.$store); |
|
|
|
|
|
|
|
|
|
mirlist().then(response => { |
|
|
|
|
let datamain = response.data; |
|
|
|
|
//routesData(datamain.data.menus); |
|
|
|
|
//console.log(response); |
|
|
|
|
console.log(this.menusdatas); |
|
|
|
|
menusdata[0].children = this.SplicingMenuTree(datamain.data.menus); |
|
|
|
|
//menusdatas[0] = addmunst |
|
|
|
|
console.log(menusdata); |
|
|
|
|
//this.routes = menusdata |
|
|
|
|
//console.log(menusdata); |
|
|
|
|
|
|
|
|
|
this.routes[0].children = this.SplicingMenuTree(datamain.data.menus); |
|
|
|
|
|
|
|
|
|
}).catch(function (error) { |
|
|
|
|
thiss.$message({ |
|
|
|
|