UserLayout.tsx 2.49 KB
Newer Older
陈小聪's avatar
陈小聪 committed
1
import SelectLang from '@/components/SelectLang';
何乐's avatar
何乐 committed
2 3
import { MenuDataItem } from '@/components/SiderMenu';
import { ConnectProps, ConnectState } from '@/models/connect';
陈小聪's avatar
陈小聪 committed
4
import getPageTitle from '@/utils/getPageTitle';
愚道's avatar
愚道 committed
5
import { GlobalFooter } from 'ant-design-pro';
陈小聪's avatar
陈小聪 committed
6 7 8
import { Icon } from 'antd';
import { connect } from 'dva';
import React, { Component, Fragment } from 'react';
Yu's avatar
Yu committed
9
import DocumentTitle from 'react-document-title';
陈小聪's avatar
陈小聪 committed
10 11
import { formatMessage } from 'umi-plugin-locale';
import Link from 'umi/link';
12
import logo from '../assets/logo.svg';
陈小聪's avatar
陈小聪 committed
13
import styles from './UserLayout.less';
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 35 36 37
const copyright = (
  <Fragment>
    Copyright <Icon type="copyright" /> 2018 蚂蚁金服体验技术部出品
  </Fragment>
);
38

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

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

57
  render() {
何乐's avatar
何乐 committed
58
    const { children, location, breadcrumbNameMap } = this.props;
59
    return (
何乐's avatar
何乐 committed
60
      <DocumentTitle title={getPageTitle(location!.pathname, breadcrumbNameMap)}>
Yu's avatar
Yu committed
61 62 63 64 65 66 67 68 69 70 71 72 73
        <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>
74
            </div>
Yu's avatar
Yu committed
75
            {children}
愚道's avatar
愚道 committed
76
          </div>
Yu's avatar
Yu committed
77
          <GlobalFooter links={links} copyright={copyright} />
78
        </div>
Yu's avatar
Yu committed
79
      </DocumentTitle>
80 81 82 83
    );
  }
}

何乐's avatar
何乐 committed
84
export default connect(({ menu: menuModel }: ConnectState) => ({
Yu's avatar
Yu committed
85 86 87
  menuData: menuModel.menuData,
  breadcrumbNameMap: menuModel.breadcrumbNameMap,
}))(UserLayout);