Skip to content

Commit af7285d

Browse files
committed
fix: vue-router.addRouters API changed warn
1 parent 37d2ff6 commit af7285d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/permission.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const defaultRoutePath = '/dashboard/workplace'
1616

1717
router.beforeEach((to, from, next) => {
1818
NProgress.start() // start progress bar
19-
to.meta && (typeof to.meta.title !== 'undefined' && setDocumentTitle(`${i18nRender(to.meta.title)} - ${domTitle}`))
19+
to.meta && typeof to.meta.title !== 'undefined' && setDocumentTitle(`${i18nRender(to.meta.title)} - ${domTitle}`)
2020
/* has token */
2121
if (storage.get(ACCESS_TOKEN)) {
2222
if (to.path === loginRoutePath) {
@@ -34,7 +34,10 @@ router.beforeEach((to, from, next) => {
3434
store.dispatch('GenerateRoutes', { roles }).then(() => {
3535
// 根据roles权限生成可访问的路由表
3636
// 动态添加可访问路由表
37-
router.addRoutes(store.getters.addRouters)
37+
// [email protected]+ New API
38+
store.getters.addRouters.forEach(r => {
39+
router.addRoute(r)
40+
})
3841
// 请求带有 redirect 重定向时,登录自动重定向到该地址
3942
const redirect = decodeURIComponent(from.query.redirect || to.path)
4043
if (to.path === redirect) {

0 commit comments

Comments
 (0)