Skip to content

Commit

Permalink
feat: render logic for dynamic routes
Browse files Browse the repository at this point in the history
  • Loading branch information
lbwa committed Oct 7, 2018
1 parent 1c09f2a commit 02a4b34
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ router.beforeEach((to, from, next) => {
throw new TypeError(role, ` should be a array`)
}
store.dispatch('login/createExtraRoutes', { role })
.then(() => router.addRoutes(store.getters['login/addRoutes']))
.catch(console.error)
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/router/routes/dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { dynamic } from '../components'
export default [
{
path: '/access/admin',
component: dynamic.permission,
component: dynamic.access,
meta: {
role: ['admin']
}
},
{
path: '/access/user',
component: dynamic.permission,
component: dynamic.access,
meta: {
role: ['user']
}
Expand Down
3 changes: 3 additions & 0 deletions src/store/modules/#/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ export default {
},
routes (state) {
return state.routes
},
addRoutes (state) {
return state.addRoutes
}
}

0 comments on commit 02a4b34

Please # to comment.