index.js 1.24 KB
Newer Older
1
import React from 'react';
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
2
import { FormattedMessage } from 'umi/locale';
zinkey's avatar
zinkey committed
3
import Link from 'umi/link';
ζ„šι“'s avatar
ζ„šι“ committed
4
import { PageHeader } from 'ant-design-pro';
5
import { connect } from 'dva';
jim's avatar
jim committed
6
import GridContent from './GridContent';
7 8
import styles from './index.less';
import MenuContext from '@/layouts/MenuContext';
9

afc163's avatar
afc163 committed
10
const PageHeaderWrapper = ({ children, contentWidth, wrapperClassName, top, ...restProps }) => (
afc163's avatar
afc163 committed
11
  <div style={{ margin: '-24px -24px 0' }} className={wrapperClassName}>
nikogu's avatar
nikogu committed
12
    {top}
jim's avatar
jim committed
13
    <MenuContext.Consumer>
14 15
      {value => (
        <PageHeader
afc163's avatar
afc163 committed
16
          wide={contentWidth === 'Fixed'}
17 18 19 20 21 22 23
          home={<FormattedMessage id="menu.home" defaultMessage="Home" />}
          {...value}
          key="pageheader"
          {...restProps}
          linkElement={Link}
          itemRender={item => {
            if (item.locale) {
24
              return <FormattedMessage id={item.locale} defaultMessage={item.title} />;
25
            }
26
            return item.title;
27 28 29
          }}
        />
      )}
jim's avatar
jim committed
30
    </MenuContext.Consumer>
jim's avatar
jim committed
31 32 33 34 35
    {children ? (
      <div className={styles.content}>
        <GridContent>{children}</GridContent>
      </div>
    ) : null}
36 37
  </div>
);
Erwin Zhang's avatar
Erwin Zhang committed
38

ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
39
export default connect(({ setting }) => ({
afc163's avatar
afc163 committed
40
  contentWidth: setting.contentWidth,
41
}))(PageHeaderWrapper);