diff --git a/site/theme/index.js b/site/theme/index.js index 51e3fb8659..8226dbcf0a 100644 --- a/site/theme/index.js +++ b/site/theme/index.js @@ -25,25 +25,25 @@ module.exports = { component: './template/Layout/index', indexRoute: { component: './template/Home/index' }, childRoutes: [{ - path: '/docs/practice/:children', + path: 'docs/practice/:children', component: contentTmpl, }, { - path: '/docs/pattern/:children', + path: 'docs/pattern/:children', component: contentTmpl, }, { - path: '/docs/react/:children', + path: 'docs/react/:children', component: contentTmpl, }, { - path: '/changelog', + path: 'changelog', component: contentTmpl, }, { - path: '/components/:children', + path: 'components/:children', component: contentTmpl, }, { - path: '/docs/spec/:children', + path: 'docs/spec/:children', component: contentTmpl, }, { - path: '/docs/resource/:children', + path: 'docs/resource/:children', component: contentTmpl, }], }, diff --git a/site/theme/template/Content/MainContent.jsx b/site/theme/template/Content/MainContent.jsx index 88cc53cc92..625e238680 100644 --- a/site/theme/template/Content/MainContent.jsx +++ b/site/theme/template/Content/MainContent.jsx @@ -6,7 +6,6 @@ import ComponentDoc from './ComponentDoc'; import * as utils from '../utils'; import config from '../../'; const SubMenu = Menu.SubMenu; -let firstMounted = false; export default class MainContent extends React.Component { static contextTypes = { @@ -14,15 +13,17 @@ export default class MainContent extends React.Component { } componentDidMount() { + this.componentDidUpdate(); + this.timer = setTimeout(() => { + document.getElementById(decodeURI(location.hash.replace('#', ''))).scrollIntoView(); + }, 10); + } + + componentDidUpdate() { if (!location.hash) { document.body.scrollTop = 0; document.documentElement.scrollTop = 0; - } else if (!firstMounted) { - this.timer = setTimeout(() => { - document.getElementById(decodeURI(location.hash.replace('#', ''))).scrollIntoView(); - }, 10); } - firstMounted = true; } componentWillUnmount() { diff --git a/site/theme/template/Layout/index.jsx b/site/theme/template/Layout/index.jsx index 0bf4a0ee3b..832cf04be7 100644 --- a/site/theme/template/Layout/index.jsx +++ b/site/theme/template/Layout/index.jsx @@ -17,7 +17,6 @@ window.antd = require('antd'); // Polyfill const areIntlLocalesSupported = require('intl-locales-supported'); const localesMyAppSupports = ['zh-CN', 'en-US']; - if (global.Intl) { // Determine if the built-in `Intl` has the locale data we need. if (!areIntlLocalesSupported(localesMyAppSupports)) { @@ -49,26 +48,24 @@ export function collect(nextProps, callback) { .then((list) => callback(null, { ...nextProps, components: list })); } -let gaListenerSetted = false; export default class Layout extends React.Component { static contextTypes = { router: React.PropTypes.object.isRequired, } componentDidMount() { - if (typeof ga !== 'undefined' && !gaListenerSetted) { + if (typeof ga !== 'undefined') { this.context.router.listen((loc) => { window.ga('send', 'pageview', loc.pathname + loc.search); }); - gaListenerSetted = true; } + const loadingNode = document.getElementById('ant-site-loading'); - if (!loadingNode) { - return; + if (loadingNode) { + this.timer = setTimeout(() => { + loadingNode.parentNode.removeChild(loadingNode); + }, 450); } - this.timer = setTimeout(() => { - loadingNode.parentNode.removeChild(loadingNode); - }, 450); } componentWillUnmount() { @@ -76,12 +73,12 @@ export default class Layout extends React.Component { } render() { - const props = this.props; + const { children, ...restProps } = this.props; return (
-
- {props.children} +
+ {children}