UserLayout.tsx 1.86 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';
duanledexianxianxian's avatar
duanledexianxianxian committed
10
import DefaultSettings from 'config/defaultSettings';
11
import logo from '../assets/logo.svg';
12
import styles from './UserLayout.less';
13

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

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

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

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