|
|
|
|
@ -25,11 +25,23 @@ router.beforeEach(async (to, from, next) => {
|
|
|
|
|
document.title = getPageTitle(to.meta.title)
|
|
|
|
|
|
|
|
|
|
if (to.query.code) {
|
|
|
|
|
console.log(to)
|
|
|
|
|
const { token } = await loginOssV2({
|
|
|
|
|
code: to.query.code
|
|
|
|
|
})
|
|
|
|
|
store.commit('user/SET_TOKEN',token)
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
roles
|
|
|
|
|
} = await store.dispatch('user/getInfo')
|
|
|
|
|
|
|
|
|
|
// generate accessible routes map based on roles
|
|
|
|
|
const accessRoutes = await store.dispatch('permission/generateRoutes', roles)
|
|
|
|
|
|
|
|
|
|
// dynamically add accessible routes
|
|
|
|
|
router.addRoutes(accessRoutes)
|
|
|
|
|
|
|
|
|
|
next('/old')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// determine whether the user has logged in
|
|
|
|
|
const hasToken = getToken()
|
|
|
|
|
|