fix: 修复菜单自动折叠的 bug

fix #229
This commit is contained in:
FairyEver 2020-04-19 11:50:32 +08:00
parent 2de8a8b7c3
commit 06f1acf522
4 changed files with 28 additions and 27 deletions

View File

@ -25,7 +25,7 @@
"countup.js": "^2.0.4",
"dayjs": "^1.8.17",
"echarts": "^4.5.0",
"element-ui": "^2.13.0",
"element-ui": "^2.13.1",
"flex.css": "^1.1.7",
"fuse.js": "^3.4.6",
"github-markdown-css": "^3.0.1",

View File

@ -1,3 +1,5 @@
import { uniqueId } from 'lodash'
// 插件
import demoPlugins from './modules/demo-plugins'
// 组件
@ -15,8 +17,23 @@ import demoD2Crud from './modules/demo-d2-crud'
// 第三方网页
import demoFrame from './modules/demo-frame'
/**
* @description 给菜单数据补充上 path 字段
* @description https://github.com/d2-projects/d2-admin/issues/209
* @param {Array} menu 原始的菜单数据
*/
function supplementPath (menu) {
return menu.map(e => ({
...e,
path: e.path || uniqueId('d2-menu-empty-'),
...e.children ? {
children: supplementPath(e.children)
} : {}
}))
}
// 菜单 侧边栏
export const menuAside = [
export const menuAside = supplementPath([
demoComponents,
demoPlugins,
demoCharts,
@ -25,10 +42,10 @@ export const menuAside = [
demoBusiness,
demoD2Crud,
demoFrame
]
])
// 菜单 顶栏
export const menuHeader = [
export const menuHeader = supplementPath([
{
path: '/index',
title: '首页',
@ -60,4 +77,4 @@ export const menuHeader = [
},
demoPlayground,
demoBusiness
]
])

View File

@ -1,22 +1,6 @@
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: {
@ -93,7 +77,7 @@ export default {
*/
headerSet (state, menu) {
// store 赋值
state.header = supplementMenuPath(menu)
state.header = menu
},
/**
* @description 设置侧边栏菜单
@ -102,7 +86,7 @@ export default {
*/
asideSet (state, menu) {
// store 赋值
state.aside = supplementMenuPath(menu)
state.aside = menu
}
}
}

View File

@ -3980,10 +3980,10 @@ element-resize-detector@^1.1.15:
dependencies:
batch-processor "^1.0.0"
element-ui@^2.13.0:
version "2.13.0"
resolved "https://registry.yarnpkg.com/element-ui/-/element-ui-2.13.0.tgz#f6bb04e5b0a76ea5f62466044b774407ba4ebd2d"
integrity sha512-KYsHWsBXYbLELS8cdfvgJTOMSUby3UEjvsPV1V1VmgJ/DdkOAS4z3MiOrPxrT9w2Cc5lZ4eVSQiGhYFR5NVChw==
element-ui@^2.13.1:
version "2.13.1"
resolved "https://registry.yarnpkg.com/element-ui/-/element-ui-2.13.1.tgz#0cb1a45cf27aa61c601defbe192740ac5cb9df7c"
integrity sha512-jyvJmXa2c6ElRc4NOw4V1vnjHsvfzTRhbwElZ68CyF9by2F64B+AJRzujg/HJgXCimHwd2g1Av9D04EP3mWymg==
dependencies:
async-validator "~1.8.1"
babel-helper-vue-jsx-merge-props "^2.0.0"