UserLayout.tsx 1.77 KB
Newer Older
1
import { ConnectProps, ConnectState } from '@/models/connect';
2
import { DefaultFooter, MenuDataItem, getMenuData, getPageTitle } from '@ant-design/pro-layout';
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
3

Yu's avatar
Yu committed
4
import DocumentTitle from 'react-document-title';
5
import Link from 'umi/link';
6 7 8 9
import React from 'react';
import SelectLang from '@/components/SelectLang';
import { connect } from 'dva';
import { formatMessage } from 'umi-plugin-react/locale';
10
import logo from '../assets/logo.svg';
11
import styles from './UserLayout.less';
12

ไฝ•ไน's avatar
ไฝ•ไน committed
13 14
export interface UserLayoutProps extends ConnectProps {
  breadcrumbNameMap: { [path: string]: MenuDataItem };
15 16
}

17 18 19 20 21 22 23 24 25 26 27 28 29
const UserLayout: React.SFC<UserLayoutProps> = props => {
  const {
    route = {
      routes: [],
    },
  } = props;
  const { routes = [] } = route;
  const {
    children,
    location = {
      pathname: '',
    },
  } = props;
30
  const { breadcrumb } = getMenuData(routes);
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

  return (
    <DocumentTitle
      title={getPageTitle({
        pathname: location.pathname,
        breadcrumb,
        formatMessage,
        ...props,
      })}
    >
      <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>
52
            </div>
53
            <div className={styles.desc}>Ant Design ๆ˜ฏ่ฅฟๆน–ๅŒบๆœ€ๅ…ทๅฝฑๅ“ๅŠ›็š„ Web ่ฎพ่ฎก่ง„่Œƒ</div>
54
          </div>
55
          {children}
56
        </div>
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
57
        <DefaultFooter />
58 59 60 61
      </div>
    </DocumentTitle>
  );
};
62

63 64 65
export default connect(({ settings }: ConnectState) => ({
  ...settings,
}))(UserLayout);