Skip to content

Commit

Permalink
fix: menuRender
Browse files Browse the repository at this point in the history
  • Loading branch information
sendya committed Jul 31, 2020
1 parent 6e46139 commit 30d1ccb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/BasicLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const BasicLayout = {
const menuHeaderRender = getComponentFromProp(content, 'menuHeaderRender')
const breadcrumbRender = getComponentFromProp(content, 'breadcrumbRender')
const headerContentRender = getComponentFromProp(content, 'headerContentRender')
const menuRender = getComponentFromProp(content, 'menuRender')

const isTopMenu = layout === 'topmenu'
const hasSiderMenu = !isTopMenu
Expand All @@ -107,7 +108,8 @@ const BasicLayout = {
rightContentRender,
collapsedButtonRender,
breadcrumbRender,
headerContentRender
headerContentRender,
menuRender
}

return (
Expand Down
12 changes: 10 additions & 2 deletions src/components/SiderMenu/SiderMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const SiderMenuProps = {
title: PropTypes.string.def(''),
// render function or vnode
menuHeaderRender: PropTypes.oneOfType([PropTypes.func, PropTypes.array, PropTypes.object, PropTypes.bool]),
menuRender: PropTypes.oneOfType([PropTypes.func, PropTypes.array, PropTypes.object, PropTypes.bool]),
}

export const defaultRenderLogo = (h, logo) => {
Expand Down Expand Up @@ -83,7 +84,8 @@ const SiderMenu = {
handleCollapse,
onMenuHeaderClick = () => null,
i18nRender,
menuHeaderRender
menuHeaderRender,
menuRender
} = this
const siderCls = ['ant-pro-sider-menu-sider']
if (fixSiderbar) siderCls.push('fix-sider-bar')
Expand Down Expand Up @@ -118,7 +120,13 @@ const SiderMenu = {
</router-link>
</div>
)}
<BaseMenu collapsed={collapsed} menus={menus} mode={mode} theme={theme} i18nRender={i18nRender} />
{menuRender && (
isFun(menuRender)
&& menuRender(h, this.$props)
|| menuRender
) || (
<BaseMenu collapsed={collapsed} menus={menus} mode={mode} theme={theme} i18nRender={i18nRender} />
)}
</Sider>)
}
}
Expand Down

0 comments on commit 30d1ccb

Please sign in to comment.