From c358efd1f454038294d23efdda8a4a768e99f3be Mon Sep 17 00:00:00 2001 From: hooray <304327508@qq.com> Date: Thu, 14 Oct 2021 19:27:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8E=E7=AB=AF=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E8=B7=AF=E7=94=B1=E9=87=8C=20auth=20=E6=97=A0?= =?UTF-8?q?=E6=95=88=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/menu.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/store/modules/menu.js b/src/store/modules/menu.js index 39eb2366..cca521a3 100644 --- a/src/store/modules/menu.js +++ b/src/store/modules/menu.js @@ -174,12 +174,20 @@ const actions = { }) }, // 生成路由(后端获取) - generateRoutesAtBack({ commit }, data) { + generateRoutesAtBack({ rootState, dispatch, commit }, data) { return new Promise(resolve => { api.get('route/list', { baseURL: '/mock/' - }).then(res => { - let accessedRoutes = formatBackRoutes(res.data) + }).then(async res => { + let asyncRoutes = formatBackRoutes(res.data) + let accessedRoutes + // 如果权限功能开启,则需要对路由数据进行筛选过滤 + if (rootState.settings.enablePermission) { + const permissions = await dispatch('user/getPermissions', null, { root: true }) + accessedRoutes = filterAsyncRoutes(asyncRoutes, permissions) + } else { + accessedRoutes = asyncRoutes + } commit('setRoutes', accessedRoutes) commit('setHeaderActived', data.currentPath) let routes = []