UserLayout.js 1.94 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

const links = [{
  title: '帮助',
  href: '',
}, {
14
  key: '隐私',
15 16 17
  title: '隐私',
  href: '',
}, {
18
  key: '隐私',
19 20 21 22 23 24 25 26
  title: '条款',
  href: '',
}];

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

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

export default UserLayout;