UserLayout.js 2.1 KB
Newer Older
1
import React from 'react';
2
import { Link, Redirect, Switch, 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';
A
afc163 已提交
7
import logo from '../assets/logo.svg';
D
ddcat1115 已提交
8
import { getRoutes } from '../utils/utils';
9 10

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

A
afc163 已提交
24
const copyright = <div>Copyright <Icon type="copyright" /> 2018 蚂蚁金服体验技术部出品</div>;
25 26 27

class UserLayout extends React.PureComponent {
  getPageTitle() {
D
ddcat1115 已提交
28
    const { routerData, location } = this.props;
D
ddcat1115 已提交
29 30
    const { pathname } = location;
    let title = 'Ant Design Pro';
D
ddcat1115 已提交
31 32 33
    if (routerData[pathname] && routerData[pathname].name) {
      title = `${routerData[pathname].name} - Ant Design Pro`;
    }
D
ddcat1115 已提交
34
    return title;
35 36
  }
  render() {
D
ddcat1115 已提交
37
    const { routerData, match } = this.props;
38 39 40
    return (
      <DocumentTitle title={this.getPageTitle()}>
        <div className={styles.container}>
41 42 43 44 45 46 47 48 49
          <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>
50
            </div>
51 52 53 54 55 56 57 58 59 60 61 62 63
            <Switch>
              {getRoutes(match.path, routerData).map(item =>
                (
                  <Route
                    key={item.key}
                    path={item.path}
                    component={item.component}
                    exact={item.exact}
                  />
                )
              )}
              <Redirect exact from="/user" to="/user/login" />
            </Switch>
64
          </div>
65
          <GlobalFooter links={links} copyright={copyright} />
66 67 68 69 70 71 72
        </div>
      </DocumentTitle>
    );
  }
}

export default UserLayout;