index.js 1.21 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';
4
import PageHeader from '@/components/PageHeader';
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

10
const PageHeaderWrapper = ({ children, grid, 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 16 17 18 19 20 21 22 23 24 25 26 27 28 29
      {value => (
        <PageHeader
          wide={grid === 'Wide'}
          home={<FormattedMessage id="menu.home" defaultMessage="Home" />}
          {...value}
          key="pageheader"
          {...restProps}
          linkElement={Link}
          itemRender={item => {
            if (item.locale) {
              return <FormattedMessage id={item.locale} defaultMessage={item.name} />;
            }
            return item.name;
          }}
        />
      )}
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 40
export default connect(({ setting }) => ({
  grid: setting.grid,
41
}))(PageHeaderWrapper);