UserLayout.js 2.21 KB
Newer Older
Yu's avatar
Yu committed
1
import React, { Component, Fragment } from 'react';
2
import { formatMessage } from 'umi/locale';
Yu's avatar
Yu committed
3
import { connect } from 'dva';
zinkey's avatar
zinkey committed
4
import Link from 'umi/link';
5
import { Icon } from 'antd';
ๆ„š้“'s avatar
ๆ„š้“ committed
6
import { GlobalFooter } from 'ant-design-pro';
Yu's avatar
Yu committed
7
import DocumentTitle from 'react-document-title';
8
import SelectLang from '@/components/SelectLang';
9
import styles from './UserLayout.less';
10
import logo from '../assets/logo.svg';
Yu's avatar
Yu committed
11
import getPageTitle from '@/utils/getPageTitle';
xiaohu's avatar
xiaohu committed
12

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

jim's avatar
jim committed
31 32 33 34 35
const copyright = (
  <Fragment>
    Copyright <Icon type="copyright" /> 2018 ่š‚่š้‡‘ๆœไฝ“้ชŒๆŠ€ๆœฏ้ƒจๅ‡บๅ“
  </Fragment>
);
36

Yu's avatar
Yu committed
37 38 39 40 41 42 43 44 45 46 47
class UserLayout extends Component {
  componentDidMount() {
    const {
      dispatch,
      route: { routes, authority },
    } = this.props;
    dispatch({
      type: 'menu/getMenuData',
      payload: { routes, authority },
    });
  }
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
48

49
  render() {
Yu's avatar
Yu committed
50 51 52 53 54
    const {
      children,
      location: { pathname },
      breadcrumbNameMap,
    } = this.props;
55
    return (
Yu's avatar
Yu committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69
      <DocumentTitle title={getPageTitle(pathname, breadcrumbNameMap)}>
        <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>
70
            </div>
Yu's avatar
Yu committed
71
            {children}
72
          </div>
Yu's avatar
Yu committed
73
          <GlobalFooter links={links} copyright={copyright} />
74
        </div>
Yu's avatar
Yu committed
75
      </DocumentTitle>
76 77 78 79
    );
  }
}

Yu's avatar
Yu committed
80 81 82 83
export default connect(({ menu: menuModel }) => ({
  menuData: menuModel.menuData,
  breadcrumbNameMap: menuModel.breadcrumbNameMap,
}))(UserLayout);