Skip to content

Commit c0dddc3

Browse files
committed
fix(route):修复路由配置中children为空的情况
1 parent 142f5e5 commit c0dddc3

4 files changed

Lines changed: 12 additions & 9 deletions

File tree

src/component/layout/breadcrumb.vue

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ export default {
2121
return this.stageInfo.map(item => item.title).filter(item => !!item)
2222
},
2323
},
24-
// created() {},
25-
// mounted() {},
26-
// watch: {},
27-
// components: {},
2824
}
2925
</script>
3026

src/plugin/custom/stage-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const CustomRouter = {
1212
title: 'upload 图像上传',
1313
type: 'view',
1414
name: 'ImgsUploadDemo',
15-
route: '/upload-image/stage1',
15+
route: '/custom/upload-image',
1616
filePath: 'plugin/custom/view/upload-image.vue',
1717
inNav: true,
1818
icon: 'iconfont icon-zidingyi',

src/router/home-router.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import stageConfig from '@/config/stage' // 引入舞台配置
22

3+
console.log('stageConfig', stageConfig)
4+
35
// 深度遍历配置树, 摘取叶子节点作为路由部分
46
function deepTravel(config, fuc) {
57
if (Array.isArray(config)) {
68
config.forEach(subConfig => {
79
deepTravel(subConfig, fuc)
810
})
9-
} else if (config.children) {
11+
} else if (config.children && config.children.length) {
1012
config.children.forEach(subConfig => {
1113
deepTravel(subConfig, fuc)
1214
})
@@ -33,4 +35,6 @@ deepTravel(stageConfig, viewConfig => {
3335
homeRouter.push(viewRouter)
3436
})
3537

38+
console.log(homeRouter)
39+
3640
export default homeRouter

src/store/getter.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ function IterationDelateMenuChildren(arr) {
3131
if (arr.length) {
3232
for (const i in arr) {
3333
if (arr[i].children && !arr[i].children.length) {
34-
delete arr[i] // eslint-disable-line
35-
} else if (arr[i].children && !arr[i].children.length) {
34+
delete arr[i].children
35+
} else if (arr[i].children && arr[i].children.length) {
3636
IterationDelateMenuChildren(arr[i].children)
3737
}
3838
}
@@ -58,8 +58,11 @@ function permissionShaking(stageConfig, permissions, currentUser) {
5858
export const permissionStageConfig = state => {
5959
const { stageConfig, permissions, user } = state // eslint-disable-line
6060
const tempStageConfig = Util.deepClone(stageConfig)
61+
console.log('0', tempStageConfig)
6162
const shookConfig = permissionShaking(tempStageConfig, permissions, user)
6263

64+
console.log('1', shookConfig)
65+
6366
// 设置舞台缓存
6467
const list = {}
6568
deepTravel(shookConfig, item => {
@@ -176,7 +179,7 @@ export const getStageInfo = state => {
176179
return result
177180
}
178181

179-
if (stages.children) {
182+
if (stages.children && stages.children.length) {
180183
result = findStage(stages.children, name)
181184
if (result) {
182185
result.unshift(stages)

0 commit comments

Comments
 (0)