Browse Source

chore: remove advertisement for yuque (#10299)

pull/10311/head
Benjy Cui 7 years ago
committed by GitHub
parent
commit
cd6ad64cab
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      site/theme/static/header.less
  2. 33
      site/theme/template/Layout/index.jsx

24
site/theme/static/header.less

@ -142,27 +142,3 @@
right: 16px;
}
}
.promote-banner {
position: relative;
display: block;
text-align: center;
background-color: #a5d6d3;
img {
max-width: 100%;
}
.anticon-cross {
position: absolute;
font-size: 24px;
cursor: pointer;
right: 24px;
top: 28px;
color: #fff;
transition: all .3s;
opacity: 0;
}
&:hover .anticon-cross {
opacity: 1;
}
}

33
site/theme/template/Layout/index.jsx

@ -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} />

Loading…
Cancel
Save