|
|
@ -1,7 +1,6 @@ |
|
|
|
import React from 'react'; |
|
|
|
import ReactDOM from 'react-dom'; |
|
|
|
import PropTypes from 'prop-types'; |
|
|
|
import { Icon } from 'antd'; |
|
|
|
import { enquireScreen } from 'enquire-js'; |
|
|
|
import { addLocaleData, IntlProvider } from 'react-intl'; |
|
|
|
import Header from './Header'; |
|
|
@ -26,8 +25,6 @@ enquireScreen((b) => { |
|
|
|
isMobile = b; |
|
|
|
}); |
|
|
|
|
|
|
|
const promoteBannerImageUrl = 'https://gw.alipayobjects.com/zos/rmsportal/bpKcpwimYnZMTarUxCEd.png'; |
|
|
|
|
|
|
|
export default class Layout extends React.Component { |
|
|
|
static contextTypes = { |
|
|
|
router: PropTypes.object.isRequired, |
|
|
@ -48,14 +45,9 @@ export default class Layout extends React.Component { |
|
|
|
const appLocale = utils.isZhCN(pathname) ? cnLocale : enLocale; |
|
|
|
addLocaleData(appLocale.data); |
|
|
|
|
|
|
|
const adBannerClosed = typeof window === 'undefined' ? true : ( |
|
|
|
window.localStorage && |
|
|
|
window.localStorage.getItem(`adBannerClosed-${promoteBannerImageUrl}`) === 'true' |
|
|
|
); |
|
|
|
this.state = { |
|
|
|
appLocale, |
|
|
|
isMobile, |
|
|
|
adBannerClosed, |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
@ -84,38 +76,13 @@ export default class Layout extends React.Component { |
|
|
|
clearTimeout(this.timer); |
|
|
|
} |
|
|
|
|
|
|
|
closePromoteBanner = (e) => { |
|
|
|
e.preventDefault(); |
|
|
|
this.makeAdBannerClosed(); |
|
|
|
} |
|
|
|
|
|
|
|
makeAdBannerClosed = () => { |
|
|
|
this.setState({ |
|
|
|
adBannerClosed: true, |
|
|
|
}); |
|
|
|
if (window.localStorage) { |
|
|
|
window.localStorage.setItem(`adBannerClosed-${promoteBannerImageUrl}`, 'true'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
render() { |
|
|
|
const { children, ...restProps } = this.props; |
|
|
|
const { appLocale } = this.state; |
|
|
|
|
|
|
|
const promoteBanner = this.state.adBannerClosed ? null : ( |
|
|
|
<a href="http://www.anijue.com/p/q/yuque423/pages/home/index.html?chInfo=ch_yuquebooks__chsub_antd" className="promote-banner" onClick={this.makeAdBannerClosed}> |
|
|
|
<img |
|
|
|
src={promoteBannerImageUrl} |
|
|
|
alt="seeconf" |
|
|
|
/> |
|
|
|
<Icon type="cross" title="close ad" onClick={this.closePromoteBanner} /> |
|
|
|
</a> |
|
|
|
); |
|
|
|
|
|
|
|
return ( |
|
|
|
<IntlProvider locale={appLocale.locale} messages={appLocale.messages}> |
|
|
|
<div className="page-wrapper"> |
|
|
|
{promoteBanner} |
|
|
|
<Header {...restProps} /> |
|
|
|
{children} |
|
|
|
<Footer {...restProps} /> |
|
|
|