UserLayout.tsx 2.49 KB
Newer Older
陈小聪's avatar
陈小聪 committed
1
import SelectLang from '@/components/SelectLang';
陈帅's avatar
陈帅 committed
2
import GlobalFooter from '@/components/GlobalFooter';
何乐's avatar
何乐 committed
3
import { ConnectProps, ConnectState } from '@/models/connect';
陈小聪's avatar
陈小聪 committed
4 5 6 7
import getPageTitle from '@/utils/getPageTitle';
import { Icon } from 'antd';
import { connect } from 'dva';
import React, { Component, Fragment } from 'react';
Yu's avatar
Yu committed
8
import DocumentTitle from 'react-document-title';
陈小聪's avatar
陈小聪 committed
9 10
import { formatMessage } from 'umi-plugin-locale';
import Link from 'umi/link';
11
import logo from '../assets/logo.svg';
陈小聪's avatar
陈小聪 committed
12
import styles from './UserLayout.less';
陈帅's avatar
陈帅 committed
13
import { MenuDataItem } from '@ant-design/pro-layout';
xiaohu's avatar
xiaohu committed
14

jim's avatar
jim committed
15 16 17
const links = [
  {
    key: 'help',
18
    title: formatMessage({ id: 'layout.user.link.help' }),
jim's avatar
jim committed
19 20 21 22
    href: '',
  },
  {
    key: 'privacy',
23
    title: formatMessage({ id: 'layout.user.link.privacy' }),
jim's avatar
jim committed
24 25 26 27
    href: '',
  },
  {
    key: 'terms',
28
    title: formatMessage({ id: 'layout.user.link.terms' }),
jim's avatar
jim committed
29 30 31
    href: '',
  },
];
32

jim's avatar
jim committed
33 34
const copyright = (
  <Fragment>
hexuebin001's avatar
hexuebin001 committed
35
    Copyright <Icon type="copyright" /> 2019 蚂蚁金服体验技术部出品
jim's avatar
jim committed
36 37
  </Fragment>
);
38

何乐's avatar
何乐 committed
39 40
export interface UserLayoutProps extends ConnectProps {
  breadcrumbNameMap: { [path: string]: MenuDataItem };
陈小聪's avatar
陈小聪 committed
41 42 43 44
  navTheme: string;
}

class UserLayout extends Component<UserLayoutProps> {
Yu's avatar
Yu committed
45
  componentDidMount() {
何乐's avatar
何乐 committed
46 47
    const { dispatch, route } = this.props;
    const { routes, authority } = route!;
何乐's avatar
何乐 committed
48
    dispatch!({
Yu's avatar
Yu committed
49 50 51 52
      type: 'menu/getMenuData',
      payload: { routes, authority },
    });
  }
陈帅's avatar
陈帅 committed
53

54
  render() {
何乐's avatar
何乐 committed
55
    const { children, location, breadcrumbNameMap } = this.props;
56
    return (
何乐's avatar
何乐 committed
57
      <DocumentTitle title={getPageTitle(location!.pathname, breadcrumbNameMap)}>
Yu's avatar
Yu committed
58 59 60 61 62 63 64 65 66 67 68 69 70
        <div className={styles.container}>
          <div className={styles.lang}>
            <SelectLang />
          </div>
          <div className={styles.content}>
            <div className={styles.top}>
              <div className={styles.header}>
                <Link to="/">
                  <img alt="logo" className={styles.logo} src={logo} />
                  <span className={styles.title}>Ant Design</span>
                </Link>
              </div>
              <div className={styles.desc}>Ant Design 是西湖区最具影响力的 Web 设计规范</div>
71
            </div>
Yu's avatar
Yu committed
72
            {children}
愚道's avatar
愚道 committed
73
          </div>
Yu's avatar
Yu committed
74
          <GlobalFooter links={links} copyright={copyright} />
75
        </div>
Yu's avatar
Yu committed
76
      </DocumentTitle>
77 78 79 80
    );
  }
}

何乐's avatar
何乐 committed
81
export default connect(({ menu: menuModel }: ConnectState) => ({
陈帅's avatar
陈帅 committed
82
  menuDaDocumentTitleta: menuModel.menuData,
Yu's avatar
Yu committed
83 84
  breadcrumbNameMap: menuModel.breadcrumbNameMap,
}))(UserLayout);