UserLayout.tsx 1.8 KB
Newer Older
陈小聪 已提交
1
import SelectLang from '@/components/SelectLang';
2 3 4
import { ConnectProps, ConnectState } from '@/models/connect';
import { connect } from 'dva';
import React from 'react';
Y
Yu 已提交
5
import DocumentTitle from 'react-document-title';
6
import { formatMessage } from 'umi-plugin-react/locale';
陈小聪 已提交
7
import Link from 'umi/link';
S
sorrycc 已提交
8
import logo from '../assets/logo.svg';
陈小聪 已提交
9
import styles from './UserLayout.less';
陈帅 已提交
10
import { MenuDataItem, getPageTitle, getMenuData, DefaultFooter } from '@ant-design/pro-layout';
11

何乐 已提交
12 13
export interface UserLayoutProps extends ConnectProps {
  breadcrumbNameMap: { [path: string]: MenuDataItem };
陈小聪 已提交
14 15
}

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

  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>
51
            </div>
52
            <div className={styles.desc}>Ant Design 是西湖区最具影响力的 Web 设计规范</div>
愚道 已提交
53
          </div>
54
          {children}
55
        </div>
陈帅 已提交
56
        <DefaultFooter />
57 58 59 60
      </div>
    </DocumentTitle>
  );
};
61

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