PageHeaderLayout.js 1.15 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';
jim's avatar
jim committed
5
import GridContent from './GridContent';
afc163's avatar
afc163 committed
6
import styles from './PageHeaderLayout.less';
7
import MenuContext from './MenuContext';
8

Erwin Zhang's avatar
Erwin Zhang committed
9
const PageHeaderLayout = ({ children, wrapperClassName, top, ...restProps }) => (
afc163's avatar
afc163 committed
10
  <div style={{ margin: '-24px -24px 0' }} className={wrapperClassName}>
nikogu's avatar
nikogu committed
11
    {top}
jim's avatar
jim committed
12
    <MenuContext.Consumer>
jim's avatar
jim committed
13
      {value => {
陈帅's avatar
陈帅 committed
14 15 16 17 18 19 20
        return (
          <PageHeader
            home={<FormattedMessage id="menu.home" defaultMessage="Home" />}
            {...value}
            key="pageheader"
            {...restProps}
            linkElement={Link}
陈帅's avatar
陈帅 committed
21 22 23 24 25 26
            itemRender={item => {
              if (item.locale) {
                return <FormattedMessage id={item.locale} defaultMessage={item.name} />;
              }
              return item.name;
            }}
陈帅's avatar
陈帅 committed
27 28
          />
        );
jim's avatar
jim committed
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 39

export default PageHeaderLayout;