UserLayout.js 2.13 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';
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
    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;