UserLayout.tsx 1.51 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 config from '@/config';
13
import styles from './UserLayout.less';
14

何乐's avatar
何乐 committed
15 16
export interface UserLayoutProps extends ConnectProps {
  breadcrumbNameMap: { [path: string]: MenuDataItem };
17 18
}

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

  return (
    <DocumentTitle
      title={getPageTitle({
        pathname: location.pathname,
        breadcrumb,
        formatMessage,
        ...props,
      })}
    >
      <div className={styles.container}>
        <div className={styles.lang}>
duanledexianxianxian's avatar
duanledexianxianxian committed
45
          <SelectLang locales={DefaultSettings.locales} />
46
        </div>
47
        <div className={styles.content}>{children}</div>
duanledexianxianxian's avatar
duanledexianxianxian committed
48
        <DefaultFooter copyright={config.copyright} links={[]}/>
49 50 51 52
      </div>
    </DocumentTitle>
  );
};
53

54 55 56
export default connect(({ settings }: ConnectState) => ({
  ...settings,
}))(UserLayout);