UserLayout.tsx 2.38 KB
Newer Older
1 2
import SelectLang from '@/components/SelectLang';
import getPageTitle from '@/utils/getPageTitle';
ๆ„š้“'s avatar
ๆ„š้“ committed
3
import { GlobalFooter } from 'ant-design-pro';
4 5 6
import { Icon } from 'antd';
import { connect } from 'dva';
import React, { Component, Fragment } from 'react';
Yu's avatar
Yu committed
7
import DocumentTitle from 'react-document-title';
8 9
import { formatMessage } from 'umi-plugin-locale';
import Link from 'umi/link';
10
import logo from '../assets/logo.svg';
11
import styles from './UserLayout.less';
xiaohu's avatar
xiaohu committed
12

jim's avatar
jim committed
13 14 15
const links = [
  {
    key: 'help',
16
    title: formatMessage({ id: 'layout.user.link.help' }),
jim's avatar
jim committed
17 18 19 20
    href: '',
  },
  {
    key: 'privacy',
21
    title: formatMessage({ id: 'layout.user.link.privacy' }),
jim's avatar
jim committed
22 23 24 25
    href: '',
  },
  {
    key: 'terms',
26
    title: formatMessage({ id: 'layout.user.link.terms' }),
jim's avatar
jim committed
27 28 29
    href: '',
  },
];
30

jim's avatar
jim committed
31 32 33 34 35
const copyright = (
  <Fragment>
    Copyright <Icon type="copyright" /> 2018 ่š‚่š้‡‘ๆœไฝ“้ชŒๆŠ€ๆœฏ้ƒจๅ‡บๅ“
  </Fragment>
);
36

37 38 39 40 41 42 43 44 45
interface UserLayoutProps {
  dispatch: (args: any) => void;
  route: any;
  breadcrumbNameMap: object;
  navTheme: string;
  location: Location;
}

class UserLayout extends Component<UserLayoutProps> {
Yu's avatar
Yu committed
46 47 48 49 50 51 52 53 54 55
  componentDidMount() {
    const {
      dispatch,
      route: { routes, authority },
    } = this.props;
    dispatch({
      type: 'menu/getMenuData',
      payload: { routes, authority },
    });
  }
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
56

57
  render() {
Yu's avatar
Yu committed
58 59 60 61 62
    const {
      children,
      location: { pathname },
      breadcrumbNameMap,
    } = this.props;
63
    return (
Yu's avatar
Yu committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77
      <DocumentTitle title={getPageTitle(pathname, breadcrumbNameMap)}>
        <div className={styles.container}>
          <div className={styles.lang}>
            <SelectLang />
          </div>
          <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>
78
            </div>
Yu's avatar
Yu committed
79
            {children}
80
          </div>
Yu's avatar
Yu committed
81
          <GlobalFooter links={links} copyright={copyright} />
82
        </div>
Yu's avatar
Yu committed
83
      </DocumentTitle>
84 85 86 87
    );
  }
}

Yu's avatar
Yu committed
88 89 90 91
export default connect(({ menu: menuModel }) => ({
  menuData: menuModel.menuData,
  breadcrumbNameMap: menuModel.breadcrumbNameMap,
}))(UserLayout);