Skip to content
This repository was archived by the owner on May 12, 2020. It is now read-only.

Commit 853e64e

Browse files
committed
feat(DynamicRoutes): re-create private routes
re-fetch user access to re-create dynamic routes and remove vuex-persistedstate
1 parent e30a93c commit 853e64e

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/permission/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function routesAddToRouter () {
5353
)
5454
}
5555

56-
function createAllRoutes (redirectPath, next) {
56+
function createAllRoutes (to, redirectPath, next) {
5757
return store.dispatch(
5858
'login/fetchUserAccess',
5959
getTokenFromLocal()
@@ -62,7 +62,9 @@ function createAllRoutes (redirectPath, next) {
6262
.then(setGlobalRoutesToStorage)
6363
.then(() => routesAddToRouter())
6464
.catch(e => errorHandler(e, next, redirectPath))
65-
.finally(next)
65+
// MUST invoke `next({ ...to, replace: true })` to prevent route matching
66+
// from occurring before route is added
67+
.finally(() => next({ ...to, replace: true }))
6668
}
6769

6870
/**
@@ -87,7 +89,7 @@ router.beforeEach((to, from, next) => {
8789
// 2.1.1 No roles: validate token (Ensure user info)
8890

8991
// 2.1.2 fetch user role
90-
return createAllRoutes(to.path, next)
92+
return createAllRoutes(to, to.path, next)
9193
}
9294

9395
// 2.2 filter route

src/store/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ export default new Vuex.Store({
2727
actions,
2828
strict: __DEV__,
2929
plugins: __DEV__
30-
? [createLogger(), persistedState]
31-
: [persistedState]
30+
? [createLogger()]
31+
: []
32+
// plugins: __DEV__
33+
// ? [createLogger(), persistedState]
34+
// : [persistedState]
3235
})

0 commit comments

Comments
 (0)