index.tsx 980 Bytes
Newer Older
1
import React from 'react';
陈帅's avatar
陈帅 committed
2
import { Drawer } from 'antd';
afc163's avatar
afc163 committed
3
import SiderMenu from './SiderMenu';
陈帅's avatar
陈帅 committed
4
import { getFlatMenuKeys } from './SiderMenuUtils';
偏右's avatar
偏右 committed
5

陈小聪's avatar
陈小聪 committed
6 7 8 9 10 11 12 13 14 15 16 17
export declare type SiderTheme = 'light' | 'dark';

interface SiderMenuProps {
  isMobile: boolean;
  menuData: any[];
  collapsed: boolean;
  logo?: string;
  theme?: SiderTheme;
  onCollapse: (payload: boolean) => void;
}

const SiderMenuWrapper: React.SFC<SiderMenuProps> = props => {
afc163's avatar
afc163 committed
18
  const { isMobile, menuData, collapsed, onCollapse } = props;
陈帅's avatar
陈帅 committed
19
  const flatMenuKeys = getFlatMenuKeys(menuData);
陈帅's avatar
陈帅 committed
20
  return isMobile ? (
陈帅's avatar
陈帅 committed
21 22 23
    <Drawer
      visible={!collapsed}
      placement="left"
afc163's avatar
afc163 committed
24
      onClose={() => onCollapse(true)}
陈帅's avatar
陈帅 committed
25 26 27 28
      style={{
        padding: 0,
        height: '100vh',
      }}
29
    >
陈帅's avatar
陈帅 committed
30
      <SiderMenu {...props} flatMenuKeys={flatMenuKeys} collapsed={isMobile ? false : collapsed} />
陈帅's avatar
陈帅 committed
31
    </Drawer>
jim's avatar
jim committed
32
  ) : (
陈帅's avatar
陈帅 committed
33
    <SiderMenu {...props} flatMenuKeys={flatMenuKeys} />
jim's avatar
jim committed
34
  );
陈小聪's avatar
陈小聪 committed
35
};
ZHAO Jinxiang's avatar
ZHAO Jinxiang committed
36

陈小聪's avatar
陈小聪 committed
37
export default React.memo(SiderMenuWrapper);