1. 在路由实例中保留基础路由
router/index.js中只需要保留基础路由,其他的都删了
2. 获取用户菜单,并保存到Vuex中
stroe/modules/user.js中,有个getInfo方法查询用户基本信息,返回了用户的菜单列表
//get user info
getInfo({ commit, state }) {return new Promise((resolve, reject) =>{
getInfo(state.token).then(response=>{
const { data }=responseif (!data) {
reject('Verification failed, please Login again.')
}
console.log(data)
const menus=[{
path:'/books',
component:'Layout',
children: [{
path:'index',
name:'AddressBook',
component:'workbench/addressbook',
meta: { title:'通讯录', icon: 'company'}
}]
},
{
path:'/systool',
component:'Layout',
redirect:'/systool/coder',
name:'SysTool',
meta: { title:'实验室', icon: 'example'},
children: [
{
path:'calendar',