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

何乐's avatar
何乐 committed
7
export { SiderMenuProps };
何乐's avatar
何乐 committed
8
export { MenuDataItem, Route } from './BaseMenu';
陈小聪's avatar
陈小聪 committed
9

何乐's avatar
何乐 committed
10
const SiderMenuWrapper: React.FC<SiderMenuProps> = props => {
afc163's avatar
afc163 committed
11
  const { isMobile, menuData, collapsed, onCollapse } = props;
陈帅's avatar
陈帅 committed
12
  const flatMenuKeys = getFlatMenuKeys(menuData);
陈帅's avatar
陈帅 committed
13
  return isMobile ? (
陈帅's avatar
陈帅 committed
14 15 16
    <Drawer
      visible={!collapsed}
      placement="left"
何乐's avatar
何乐 committed
17
      onClose={() => onCollapse!(true)}
陈帅's avatar
陈帅 committed
18 19 20 21
      style={{
        padding: 0,
        height: '100vh',
      }}
22
    >
陈帅's avatar
陈帅 committed
23
      <SiderMenu {...props} flatMenuKeys={flatMenuKeys} collapsed={isMobile ? false : collapsed} />
陈帅's avatar
陈帅 committed
24
    </Drawer>
jim's avatar
jim committed
25
  ) : (
陈帅's avatar
陈帅 committed
26
    <SiderMenu {...props} flatMenuKeys={flatMenuKeys} />
jim's avatar
jim committed
27
  );
陈小聪's avatar
陈小聪 committed
28
};
ZHAO Jinxiang's avatar
ZHAO Jinxiang committed
29

何乐's avatar
何乐 committed
30 31 32 33
SiderMenuWrapper.defaultProps = {
  onCollapse: () => void 0,
};

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