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

const links = [{
afc163's avatar
afc163 committed
11
  key: 'help',
12 13 14
  title: '帮助',
  href: '',
}, {
afc163's avatar
afc163 committed
15
  key: 'privacy',
16 17 18
  title: '隐私',
  href: '',
}, {
afc163's avatar
afc163 committed
19
  key: 'terms',
20 21 22 23
  title: '条款',
  href: '',
}];

afc163's avatar
afc163 committed
24
const copyright = <div>Copyright <Icon type="copyright" /> 2018 蚂蚁金服体验技术部出品</div>;
25 26 27

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

export default UserLayout;