Commit a5907a30 authored by jim's avatar jim

fix #1248 match params path

parent 6481a3af
...@@ -6,6 +6,7 @@ import { connect } from 'dva'; ...@@ -6,6 +6,7 @@ import { connect } from 'dva';
import { Route, Redirect, Switch, routerRedux } from 'dva/router'; import { Route, Redirect, Switch, routerRedux } from 'dva/router';
import { ContainerQuery } from 'react-container-query'; import { ContainerQuery } from 'react-container-query';
import classNames from 'classnames'; import classNames from 'classnames';
import pathToRegexp from 'path-to-regexp';
import { enquireScreen, unenquireScreen } from 'enquire-js'; import { enquireScreen, unenquireScreen } from 'enquire-js';
import GlobalHeader from '../components/GlobalHeader'; import GlobalHeader from '../components/GlobalHeader';
import GlobalFooter from '../components/GlobalFooter'; import GlobalFooter from '../components/GlobalFooter';
...@@ -108,15 +109,22 @@ class BasicLayout extends React.PureComponent { ...@@ -108,15 +109,22 @@ class BasicLayout extends React.PureComponent {
type: 'user/fetchCurrent', type: 'user/fetchCurrent',
}); });
} }
componentWillUnmount(){ componentWillUnmount() {
unenquireScreen(this.enquireHandler); unenquireScreen(this.enquireHandler);
} }
getPageTitle() { getPageTitle() {
const { routerData, location } = this.props; const { routerData, location } = this.props;
const { pathname } = location; const { pathname } = location;
let title = 'Ant Design Pro'; let title = 'Ant Design Pro';
if (routerData[pathname] && routerData[pathname].name) { let currRouterData = null;
title = `${routerData[pathname].name} - Ant Design Pro`; // match params path
Object.keys(routerData).forEach(key => {
if (pathToRegexp(key).test(pathname)) {
currRouterData = routerData[key];
}
});
if (currRouterData && currRouterData.name) {
title = `${currRouterData.name} - Ant Design Pro`;
} }
return title; return title;
} }
......
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