Commit fc136b6a authored by ι™ˆεΈ…'s avatar ι™ˆεΈ…

bugfix: fix #4349,UserLayout getPageTitle doesn't show title

parent 820b6391
import SelectLang from '@/components/SelectLang'; import SelectLang from '@/components/SelectLang';
import GlobalFooter from '@/components/GlobalFooter'; import GlobalFooter from '@/components/GlobalFooter';
import { ConnectProps } from '@/models/connect'; import { ConnectProps, ConnectState } from '@/models/connect';
import { connect } from 'dva';
import { Icon } from 'antd'; import { Icon } from 'antd';
import React, { Component, Fragment } from 'react'; import React from 'react';
import DocumentTitle from 'react-document-title'; import DocumentTitle from 'react-document-title';
import { formatMessage } from 'umi-plugin-locale'; import { formatMessage } from 'umi-plugin-react/locale';
import Link from 'umi/link'; import Link from 'umi/link';
import logo from '../assets/logo.svg'; import logo from '../assets/logo.svg';
import styles from './UserLayout.less'; import styles from './UserLayout.less';
...@@ -29,32 +30,37 @@ const links = [ ...@@ -29,32 +30,37 @@ const links = [
]; ];
const copyright = ( const copyright = (
<Fragment> <>
Copyright <Icon type="copyright" /> 2019 θš‚θšι‡‘ζœδ½“ιͺŒζŠ€ζœ―部出品 Copyright <Icon type="copyright" /> 2019 θš‚θšι‡‘ζœδ½“ιͺŒζŠ€ζœ―部出品
</Fragment> </>
); );
export interface UserLayoutProps extends ConnectProps { export interface UserLayoutProps extends ConnectProps {
breadcrumbNameMap: { [path: string]: MenuDataItem }; breadcrumbNameMap: { [path: string]: MenuDataItem };
navTheme: string;
} }
class UserLayout extends Component<UserLayoutProps> { const UserLayout: React.SFC<UserLayoutProps> = props => {
render() {
const { const {
route = { route = {
routes: [], routes: [],
}, },
} = this.props; } = props;
const { routes = [] } = route; const { routes = [] } = route;
const { children, location } = this.props; const {
const { breadcrumb } = getMenuData(routes, this.props); children,
location = {
pathname: '',
},
} = props;
const { breadcrumb } = getMenuData(routes, props);
return ( return (
<DocumentTitle <DocumentTitle
title={getPageTitle({ title={getPageTitle({
pathname: location!.pathname, pathname: location.pathname,
breadcrumb, breadcrumb,
formatMessage, formatMessage,
...props,
})} })}
> >
<div className={styles.container}> <div className={styles.container}>
...@@ -77,7 +83,8 @@ class UserLayout extends Component<UserLayoutProps> { ...@@ -77,7 +83,8 @@ class UserLayout extends Component<UserLayoutProps> {
</div> </div>
</DocumentTitle> </DocumentTitle>
); );
} };
}
export default UserLayout; export default connect(({ settings }: ConnectState) => ({
...settings,
}))(UserLayout);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment