Unverified Commit de613635 by Sendya

fix: router alwaysShow rename hideChildrenInMenu

parent d74030c3
......@@ -66,8 +66,9 @@ export default {
return h(Icon, { props: { ...props } })
},
renderMenuItem: function (h, menu, pIndex, index) {
const target = menu.meta.target || null
return h(Item, { key: menu.path ? menu.path : 'item_' + pIndex + '_' + index }, [
h('router-link', { attrs: { to: { name: menu.name } } }, [
h('router-link', { attrs: { to: { name: menu.name }, target: target } }, [
this.renderIcon(h, menu.meta.icon),
h('span', [menu.meta.title])
])
......@@ -78,7 +79,8 @@ export default {
const subItem = [h('span', { slot: 'title' }, [this.renderIcon(h, menu.meta.icon), h('span', [menu.meta.title])])]
const itemArr = []
const pIndex_ = pIndex + '_' + index
if (!menu.alwaysShow) {
console.log('menu', menu)
if (!menu.hideChildrenInMenu) {
menu.children.forEach(function (item, i) {
itemArr.push(this2_.renderItem(h, item, pIndex_, i))
})
......@@ -87,7 +89,7 @@ export default {
},
renderItem: function (h, menu, pIndex, index) {
if (!menu.hidden) {
return menu.children && !menu.alwaysShow
return menu.children && !menu.hideChildrenInMenu
? this.renderSubMenu(h, menu, pIndex, index)
: this.renderMenuItem(h, menu, pIndex, index)
}
......
......@@ -131,7 +131,6 @@ export default {
}, 16)
})
}
},
methods: {
...mapActions(['setSidebar']),
......
......@@ -80,7 +80,7 @@ export const asyncRouterMap = [
{
path: '/list/query-list',
name: 'QueryListWrapper',
alwaysShow: true, // 强制显示 MenuItem 而不是 SubMenu
hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
component: () => import('@/views/list/TableList'),
meta: { title: '查询表格', keepAlive: true, permission: [ 'table' ] }
},
......@@ -257,7 +257,7 @@ export const asyncRouterMap = [
component: () => import('@/views/account/settings/Index'),
meta: { title: '个人设置', hideHeader: true, keepAlive: true, permission: [ 'user' ] },
redirect: '/account/settings/base',
alwaysShow: true,
hideChildrenInMenu: true,
children: [
{
path: '/account/settings/base',
......
......@@ -42,7 +42,7 @@
| redirect | 重定向地址, 访问这个路由时,自定进行重定向 | string | - |
| name | 路由名称, 必须设置,且不能重名 | string | - |
| meta | 路由元信息(路由附带扩展信息) | object | {} |
| alwaysShow | 强制菜单显示为Item而不是SubItem(配合 meta.hidden) | boolean | - |
| hideChildrenInMenu | 强制菜单显示为Item而不是SubItem(配合 meta.hidden) | boolean | - |
`{ Meta }` 路由元信息对象
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment