|
|
@@ -111,8 +111,8 @@ router.beforeEach((to, from, next) => {
|
|
|
if (store.getters.roles.length === 0) { // 判断当前用户是否已拉取完user_info信息
|
|
|
store.dispatch('GetUserInfo').then(res => {
|
|
|
store.dispatch('GetUserMenus').then(res => { // 拉取user_info
|
|
|
- // const roles = res.data.data // note: roles must be a array! such as: ['editor','develop']
|
|
|
- const roles = myRoles;
|
|
|
+ const roles = res.data.data // note: roles must be a array! such as: ['editor','develop']
|
|
|
+ // const roles = myRoles;
|
|
|
store.dispatch('GenerateRoutes', { roles }).then(() => { // 根据roles权限生成可访问的路由表
|
|
|
router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表
|
|
|
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
|
|
|
@@ -122,13 +122,7 @@ router.beforeEach((to, from, next) => {
|
|
|
}).catch(() => {
|
|
|
store.dispatch('FedLogOut').then(() => {
|
|
|
Message.error('Verification failed, please login again')
|
|
|
- // const prodHref = 'http://dgt.dgtis.com/oneportal/login';//正式地址
|
|
|
-
|
|
|
- const prodHref = 'http://dgtcloud.dgtis.com/oneportal/login';//阿里云地址
|
|
|
-
|
|
|
- const devHref = 'http://192.168.100.87:8080/oneportal/login';//测试地址
|
|
|
-
|
|
|
- location.href = process.env.NODE_ENV === 'production' ? prodHref : devHref;
|
|
|
+ location.href = process.env.OS_API;
|
|
|
// next({ path: '/login' })
|
|
|
})
|
|
|
})
|
|
|
@@ -147,13 +141,7 @@ router.beforeEach((to, from, next) => {
|
|
|
if (whiteList.indexOf(to.path) !== -1) { // 在免登录白名单,直接进入
|
|
|
next()
|
|
|
} else {
|
|
|
- // const prodHref = 'http://dgt.dgtis.com/oneportal/login';//正式地址
|
|
|
-
|
|
|
- const prodHref = 'http://dgtcloud.dgtis.com/oneportal/login';//阿里云地址
|
|
|
-
|
|
|
- const devHref = 'http://192.168.100.87:8080/oneportal/login';//测试地址
|
|
|
-
|
|
|
- location.href = process.env.NODE_ENV === 'production' ? prodHref : devHref;
|
|
|
+ location.href = process.env.OS_API;
|
|
|
// next('/login') // 否则全部重定向到登录页
|
|
|
NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
|
|
|
}
|