Skip to content

Commit f82da10

Browse files
committed
fix: 修复路由sharking逻辑
1 parent c0dddc3 commit f82da10

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/store/getter.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ export const readedMessages = state => state.readedMessages
2727

2828
export const unreadMessages = state => state.unreadMessages
2929

30+
/**
31+
* 在侧边栏展示时,如果当前路由 children 属性为空,则删除该路由
32+
* @param {*} arr 路由配置项数据
33+
*/
3034
function IterationDelateMenuChildren(arr) {
3135
if (arr.length) {
3236
for (const i in arr) {
3337
if (arr[i].children && !arr[i].children.length) {
34-
delete arr[i].children
38+
delete arr[i]
3539
} else if (arr[i].children && arr[i].children.length) {
3640
IterationDelateMenuChildren(arr[i].children)
3741
}
@@ -40,12 +44,17 @@ function IterationDelateMenuChildren(arr) {
4044
return arr
4145
}
4246

47+
/**
48+
* Shaking 掉无限制路由
49+
* @param {array} stageConfig 路由配置项数据
50+
* @param {array} permissions 当前登录管理员所拥有的权限集合
51+
* @param {object} currentUser 当前登录管理员
52+
*/
4353
function permissionShaking(stageConfig, permissions, currentUser) {
44-
// eslint-disable-line
4554
const shookConfig = stageConfig.filter(route => {
4655
if (Util.hasPermission(permissions, route, currentUser)) {
4756
if (route.children && route.children.length) {
48-
route.children = permissionShaking(route.children, permissions, currentUser) // eslint-disable-line
57+
route.children = permissionShaking(route.children, permissions, currentUser)
4958
}
5059
return true
5160
}
@@ -58,11 +67,8 @@ function permissionShaking(stageConfig, permissions, currentUser) {
5867
export const permissionStageConfig = state => {
5968
const { stageConfig, permissions, user } = state // eslint-disable-line
6069
const tempStageConfig = Util.deepClone(stageConfig)
61-
console.log('0', tempStageConfig)
6270
const shookConfig = permissionShaking(tempStageConfig, permissions, user)
6371

64-
console.log('1', shookConfig)
65-
6672
// 设置舞台缓存
6773
const list = {}
6874
deepTravel(shookConfig, item => {

0 commit comments

Comments
 (0)