diff --git a/src/router/index.js b/src/router/index.js index acb05305..523a68ba 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -150,14 +150,9 @@ router.beforeEach(async(to, from, next) => { } else { let accessRoutes = [] if (!store.state.settings.enableBackendReturnRoute) { - accessRoutes = await store.dispatch('menu/generateRoutesAtFront', { - asyncRoutes, - currentPath: to.path - }) + accessRoutes = await store.dispatch('menu/generateRoutesAtFront', asyncRoutes) } else { - accessRoutes = await store.dispatch('menu/generateRoutesAtBack', { - currentPath: to.path - }) + accessRoutes = await store.dispatch('menu/generateRoutesAtBack') } accessRoutes.push(lastRoute) let removeRoutes = [] diff --git a/src/store/modules/menu.js b/src/store/modules/menu.js index 3e2b57e6..4b6a143b 100644 --- a/src/store/modules/menu.js +++ b/src/store/modules/menu.js @@ -169,19 +169,18 @@ const getters = { const actions = { // 根据权限动态生成路由(前端生成) - generateRoutesAtFront({ rootState, dispatch, commit }, data) { + generateRoutesAtFront({ rootState, dispatch, commit }, asyncRoutes) { // eslint-disable-next-line no-async-promise-executor return new Promise(async resolve => { let accessedRoutes // 如果权限功能开启,则需要对路由数据进行筛选过滤 if (rootState.settings.enablePermission) { const permissions = await dispatch('user/getPermissions', null, { root: true }) - accessedRoutes = filterAsyncRoutes(data.asyncRoutes, permissions) + accessedRoutes = filterAsyncRoutes(asyncRoutes, permissions) } else { - accessedRoutes = deepClone(data.asyncRoutes) + accessedRoutes = deepClone(asyncRoutes) } commit('setRoutes', accessedRoutes) - commit('setHeaderActived', data.currentPath) let routes = [] accessedRoutes.map(item => { routes.push(...item.children) @@ -200,7 +199,7 @@ const actions = { }) }, // 生成路由(后端获取) - generateRoutesAtBack({ rootState, dispatch, commit }, data) { + generateRoutesAtBack({ rootState, dispatch, commit }) { return new Promise(resolve => { api.get('route/list', { baseURL: '/mock/' @@ -215,7 +214,6 @@ const actions = { accessedRoutes = deepClone(asyncRoutes) } commit('setRoutes', accessedRoutes) - commit('setHeaderActived', data.currentPath) let routes = [] accessedRoutes.map(item => { routes.push(...item.children)