Former-commit-id: a028cd2bfb5d361eeb019eafc1203d26fd68a35e
This commit is contained in:
FairyEver
2019-08-11 00:11:13 +08:00
parent 1ae45c5f62
commit ac906425c0
3 changed files with 25 additions and 16 deletions
+18 -2
View File
@@ -1,6 +1,22 @@
import { uniqueId } from 'lodash'
// 设置文件
import setting from '@/setting.js'
/**
* 给菜单数据补充上 path 字段
* https://github.com/d2-projects/d2-admin/issues/209
* @param {Array} menu 原始的菜单数据
*/
function supplementMenuPath (menu) {
return menu.map(e => ({
...e,
path: e.path || uniqueId('d2-menu-empty-'),
...e.children ? {
children: supplementMenuPath(e.children)
} : {}
}))
}
export default {
namespaced: true,
state: {
@@ -77,7 +93,7 @@ export default {
*/
headerSet (state, menu) {
// store 赋值
state.header = menu
state.header = supplementMenuPath(menu)
},
/**
* @description 设置侧边栏菜单
@@ -86,7 +102,7 @@ export default {
*/
asideSet (state, menu) {
// store 赋值
state.aside = menu
state.aside = supplementMenuPath(menu)
}
}
}