index.js 975 Bytes
Newer Older
jiang's avatar
jiang committed
1
import 'rc-drawer-menu/assets/index.css';
偏右's avatar
偏右 committed
2
import React, { PureComponent } from 'react';
jiang's avatar
jiang committed
3 4
import DrawerMenu from 'rc-drawer-menu';
import SiderMenu from './SiderMenu';
偏右's avatar
偏右 committed
5

jiang's avatar
jiang committed
6
export default class Index extends PureComponent {
偏右's avatar
偏右 committed
7 8 9 10 11 12
  onCollapse = (collapsed) => {
    this.props.dispatch({
      type: 'global/changeLayoutCollapsed',
      payload: collapsed,
    });
  }
ddcat1115's avatar
ddcat1115 committed
13

偏右's avatar
偏右 committed
14
  render() {
jiang's avatar
jiang committed
15 16 17 18 19 20 21 22 23
    const { collapsed, isMobile } = this.props;
    return isMobile ? (
      <DrawerMenu
        parent={null}
        level={null}
        iconChild={null}
        open={!collapsed}
        onMaskClick={() => { this.onCollapse(true); }}
        width="256px"
偏右's avatar
偏右 committed
24
      >
jiang's avatar
jiang committed
25 26 27 28 29 30 31 32 33 34 35 36 37
        <SiderMenu
          {...this.props}
          isMobile={isMobile}
          onCollapse={this.onCollapse}
          collapsed={isMobile ? false : collapsed}
        />
      </DrawerMenu>
    ) : (
      <SiderMenu
        {...this.props}
        isMobile={isMobile}
        onCollapse={this.onCollapse}
      />
偏右's avatar
偏右 committed
38 39 40
    );
  }
}