Merge branch 'master' of github.com:ant-design/ant-design

This commit is contained in:
afc163 2016-07-27 12:59:09 +08:00
commit 2af8f6f95c
3 changed files with 23 additions and 25 deletions

View File

@ -25,25 +25,25 @@ module.exports = {
component: './template/Layout/index', component: './template/Layout/index',
indexRoute: { component: './template/Home/index' }, indexRoute: { component: './template/Home/index' },
childRoutes: [{ childRoutes: [{
path: '/docs/practice/:children', path: 'docs/practice/:children',
component: contentTmpl, component: contentTmpl,
}, { }, {
path: '/docs/pattern/:children', path: 'docs/pattern/:children',
component: contentTmpl, component: contentTmpl,
}, { }, {
path: '/docs/react/:children', path: 'docs/react/:children',
component: contentTmpl, component: contentTmpl,
}, { }, {
path: '/changelog', path: 'changelog',
component: contentTmpl, component: contentTmpl,
}, { }, {
path: '/components/:children', path: 'components/:children',
component: contentTmpl, component: contentTmpl,
}, { }, {
path: '/docs/spec/:children', path: 'docs/spec/:children',
component: contentTmpl, component: contentTmpl,
}, { }, {
path: '/docs/resource/:children', path: 'docs/resource/:children',
component: contentTmpl, component: contentTmpl,
}], }],
}, },

View File

@ -6,7 +6,6 @@ import ComponentDoc from './ComponentDoc';
import * as utils from '../utils'; import * as utils from '../utils';
import config from '../../'; import config from '../../';
const SubMenu = Menu.SubMenu; const SubMenu = Menu.SubMenu;
let firstMounted = false;
export default class MainContent extends React.Component { export default class MainContent extends React.Component {
static contextTypes = { static contextTypes = {
@ -14,15 +13,17 @@ export default class MainContent extends React.Component {
} }
componentDidMount() { componentDidMount() {
this.componentDidUpdate();
this.timer = setTimeout(() => {
document.getElementById(decodeURI(location.hash.replace('#', ''))).scrollIntoView();
}, 10);
}
componentDidUpdate() {
if (!location.hash) { if (!location.hash) {
document.body.scrollTop = 0; document.body.scrollTop = 0;
document.documentElement.scrollTop = 0; document.documentElement.scrollTop = 0;
} else if (!firstMounted) {
this.timer = setTimeout(() => {
document.getElementById(decodeURI(location.hash.replace('#', ''))).scrollIntoView();
}, 10);
} }
firstMounted = true;
} }
componentWillUnmount() { componentWillUnmount() {

View File

@ -17,7 +17,6 @@ window.antd = require('antd');
// Polyfill // Polyfill
const areIntlLocalesSupported = require('intl-locales-supported'); const areIntlLocalesSupported = require('intl-locales-supported');
const localesMyAppSupports = ['zh-CN', 'en-US']; const localesMyAppSupports = ['zh-CN', 'en-US'];
if (global.Intl) { if (global.Intl) {
// Determine if the built-in `Intl` has the locale data we need. // Determine if the built-in `Intl` has the locale data we need.
if (!areIntlLocalesSupported(localesMyAppSupports)) { if (!areIntlLocalesSupported(localesMyAppSupports)) {
@ -49,26 +48,24 @@ export function collect(nextProps, callback) {
.then((list) => callback(null, { ...nextProps, components: list })); .then((list) => callback(null, { ...nextProps, components: list }));
} }
let gaListenerSetted = false;
export default class Layout extends React.Component { export default class Layout extends React.Component {
static contextTypes = { static contextTypes = {
router: React.PropTypes.object.isRequired, router: React.PropTypes.object.isRequired,
} }
componentDidMount() { componentDidMount() {
if (typeof ga !== 'undefined' && !gaListenerSetted) { if (typeof ga !== 'undefined') {
this.context.router.listen((loc) => { this.context.router.listen((loc) => {
window.ga('send', 'pageview', loc.pathname + loc.search); window.ga('send', 'pageview', loc.pathname + loc.search);
}); });
gaListenerSetted = true;
} }
const loadingNode = document.getElementById('ant-site-loading'); const loadingNode = document.getElementById('ant-site-loading');
if (!loadingNode) { if (loadingNode) {
return; this.timer = setTimeout(() => {
loadingNode.parentNode.removeChild(loadingNode);
}, 450);
} }
this.timer = setTimeout(() => {
loadingNode.parentNode.removeChild(loadingNode);
}, 450);
} }
componentWillUnmount() { componentWillUnmount() {
@ -76,12 +73,12 @@ export default class Layout extends React.Component {
} }
render() { render() {
const props = this.props; const { children, ...restProps } = this.props;
return ( return (
<IntlProvider locale={appLocale.locale} messages={appLocale.messages}> <IntlProvider locale={appLocale.locale} messages={appLocale.messages}>
<div className="page-wrapper"> <div className="page-wrapper">
<Header {...props} /> <Header {...restProps} />
{props.children} {children}
<Footer /> <Footer />
</div> </div>
</IntlProvider> </IntlProvider>