From 255a70b677d48317908e43bd5aee9c786397d14f Mon Sep 17 00:00:00 2001 From: jim Date: Mon, 14 May 2018 09:40:50 +0800 Subject: [PATCH] Optimize fixSiderbar --- src/components/SiderMenu/index.js | 2 +- src/layouts/BasicLayout.js | 30 +++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/components/SiderMenu/index.js b/src/components/SiderMenu/index.js index 8b73a38e..3ec398b2 100644 --- a/src/components/SiderMenu/index.js +++ b/src/components/SiderMenu/index.js @@ -20,7 +20,7 @@ const getFlatMenuKeys = menuData => { }; const SiderMenuWrapper = props => - props.isMobile || props.fixSiderbar ? ( + props.isMobile ? ( { + const { fixSiderbar } = this.props; + if (fixSiderbar) { + return { + height: '100vh', + overflow: 'auto', + }; + } + return null; + }; + getContentStyle = () => { + const { fixedHeader } = this.props; + return { + margin: '24px 24px 0', + paddingTop: fixedHeader ? 64 : 0, + }; + }; getBashRedirect = () => { // According to the url parameter to redirect // 这里是重定向的,重定向到 url 的 redirect 参数所示地址 @@ -101,8 +118,9 @@ class BasicLayout extends React.PureComponent { payload: collapsed, }); }; + render() { - const { isMobile, redirectData, routerData, fixedHeader, match } = this.props; + const { isMobile, redirectData, routerData, match } = this.props; const isTop = this.props.layout === 'topmenu'; const bashRedirect = this.getBashRedirect(); const myRedirectData = redirectData || []; @@ -117,15 +135,9 @@ class BasicLayout extends React.PureComponent { {...this.props} /> )} - +
- + {myRedirectData.map(item => ( -- GitLab