Browse Source

Optimize fixSiderbar

pull/1528/head
jim 8 years ago
committed by 陈帅
parent
commit
255a70b677
  1. 2
      src/components/SiderMenu/index.js
  2. 30
      src/layouts/BasicLayout.js

2
src/components/SiderMenu/index.js

@ -20,7 +20,7 @@ const getFlatMenuKeys = menuData => {
}; };
const SiderMenuWrapper = props => const SiderMenuWrapper = props =>
props.isMobile || props.fixSiderbar ? ( props.isMobile ? (
<DrawerMenu <DrawerMenu
parent={null} parent={null}
level={null} level={null}

30
src/layouts/BasicLayout.js

@ -75,6 +75,23 @@ class BasicLayout extends React.PureComponent {
} }
return title; return title;
} }
getLayoutStyle = () => {
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 = () => { getBashRedirect = () => {
// According to the url parameter to redirect // According to the url parameter to redirect
// 这里是重定向的,重定向到 url 的 redirect 参数所示地址 // 这里是重定向的,重定向到 url 的 redirect 参数所示地址
@ -101,8 +118,9 @@ class BasicLayout extends React.PureComponent {
payload: collapsed, payload: collapsed,
}); });
}; };
render() { render() {
const { isMobile, redirectData, routerData, fixedHeader, match } = this.props; const { isMobile, redirectData, routerData, match } = this.props;
const isTop = this.props.layout === 'topmenu'; const isTop = this.props.layout === 'topmenu';
const bashRedirect = this.getBashRedirect(); const bashRedirect = this.getBashRedirect();
const myRedirectData = redirectData || []; const myRedirectData = redirectData || [];
@ -117,15 +135,9 @@ class BasicLayout extends React.PureComponent {
{...this.props} {...this.props}
/> />
)} )}
<Layout> <Layout style={this.getLayoutStyle()}>
<Header handleMenuCollapse={this.handleMenuCollapse} logo={logo} {...this.props} /> <Header handleMenuCollapse={this.handleMenuCollapse} logo={logo} {...this.props} />
<Content <Content style={this.getContentStyle()}>
style={{
margin: '24px 24px 0',
height: '100%',
paddingTop: fixedHeader ? 64 : 0,
}}
>
<Switch> <Switch>
{myRedirectData.map(item => ( {myRedirectData.map(item => (
<Redirect key={item.from} exact from={item.from} to={item.to} /> <Redirect key={item.from} exact from={item.from} to={item.to} />

Loading…
Cancel
Save