From 5117b13e5e6d4edc85be0ffcbfe2974b05c65d3f Mon Sep 17 00:00:00 2001 From: BoBoooooo <17746714@qq.com> Date: Tue, 4 Dec 2018 23:46:28 +0800 Subject: [PATCH] some change --- src/permission.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/permission.js b/src/permission.js index 7e596c0..dad5fbe 100644 --- a/src/permission.js +++ b/src/permission.js @@ -14,17 +14,20 @@ router.beforeEach((to, from, next) => { next({ path: '/' }) - } else { + } else { if (store.getters.addRouters.length === 0) { store.dispatch('GetInfo').then(res => { // 拉取user_info - const roleauthname = res.RoleAuthName.split(',') - store.dispatch('GenerateRoutes', { roleauthname }).then(() => { // 根据roles权限生成可访问的路由表 + const roleauthname = res.RoleAuthName.split(',') + store.dispatch('GenerateRoutes', { + roleauthname + }).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 + next({ ...to, + replace: true + }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record }) }) - } - else { + } else { next() } }