UserLayout.js 1.91 KB
Newer Older
1
import React from 'react';
ddcat1115's avatar
ddcat1115 committed
2
import { Link, Route } from 'dva/router';
3 4 5 6
import DocumentTitle from 'react-document-title';
import { Icon } from 'antd';
import GlobalFooter from '../components/GlobalFooter';
import styles from './UserLayout.less';
afc163's avatar
afc163 committed
7
import logo from '../assets/logo.svg';
ddcat1115's avatar
ddcat1115 committed
8
import { getRoutes } from '../utils/utils';
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

const links = [{
  title: '帮助',
  href: '',
}, {
  title: '隐私',
  href: '',
}, {
  title: '条款',
  href: '',
}];

const copyright = <div>Copyright <Icon type="copyright" /> 2017 蚂蚁金服体验技术部出品</div>;

class UserLayout extends React.PureComponent {
  getPageTitle() {
ddcat1115's avatar
ddcat1115 committed
25
    const { routerData, location } = this.props;
ddcat1115's avatar
ddcat1115 committed
26 27
    const { pathname } = location;
    let title = 'Ant Design Pro';
ddcat1115's avatar
ddcat1115 committed
28 29 30
    if (routerData[pathname] && routerData[pathname].name) {
      title = `${routerData[pathname].name} - Ant Design Pro`;
    }
ddcat1115's avatar
ddcat1115 committed
31
    return title;
32 33
  }
  render() {
ddcat1115's avatar
ddcat1115 committed
34
    const { routerData, match } = this.props;
35 36 37 38 39
    return (
      <DocumentTitle title={this.getPageTitle()}>
        <div className={styles.container}>
          <div className={styles.top}>
            <div className={styles.header}>
ddcat1115's avatar
ddcat1115 committed
40
              <Link to="/">
afc163's avatar
afc163 committed
41
                <img alt="logo" className={styles.logo} src={logo} />
ddcat1115's avatar
ddcat1115 committed
42 43
                <span className={styles.title}>Ant Design</span>
              </Link>
44
            </div>
afc163's avatar
afc163 committed
45
            <div className={styles.desc}>Ant Design 是西湖区最具影响力的 Web 设计规范</div>
46
          </div>
ddcat1115's avatar
ddcat1115 committed
47
          {
ddcat1115's avatar
ddcat1115 committed
48
            getRoutes(match.path, routerData).map(item =>
ddcat1115's avatar
ddcat1115 committed
49 50
              (
                <Route
ddcat1115's avatar
ddcat1115 committed
51
                  key={item.key}
ddcat1115's avatar
ddcat1115 committed
52
                  path={item.path}
53
                  component={item.component}
ddcat1115's avatar
ddcat1115 committed
54
                  exact={item.exact}
ddcat1115's avatar
ddcat1115 committed
55 56 57 58
                />
              )
            )
          }
59 60 61 62 63 64 65 66
          <GlobalFooter className={styles.footer} links={links} copyright={copyright} />
        </div>
      </DocumentTitle>
    );
  }
}

export default UserLayout;