Skip to content

Commit 99bf304

Browse files
committed
docs: update ad
1 parent f05387d commit 99bf304

File tree

4 files changed

+84
-77
lines changed

4 files changed

+84
-77
lines changed

site/components/CarbonAds.vue

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<script>
2+
const carbonUrls = {
3+
'vuecomponent.github.io':'//cdn.carbonads.com/carbon.js?serve=CK7DL2JW&placement=vuecomponentgithubio',
4+
'tangjinzhou.gitee.io':'//cdn.carbonads.com/carbon.js?serve=CK7DL2JN&placement=tangjinzhougiteeio',
5+
};
6+
const carbonUrl = carbonUrls[location.host];
7+
export default {
8+
mounted() {
9+
this.load();
10+
},
11+
watch: {
12+
$route(e, t) {
13+
if(e.path !== t.path && this.$el.querySelector("#carbonads")){
14+
this.$el.innerHTML = "";
15+
this.load();
16+
}
17+
},
18+
},
19+
methods: {
20+
load() {
21+
if(carbonUrl) {
22+
const e = document.createElement("script");
23+
e.id = "_carbonads_js";
24+
e.src = carbonUrl;
25+
this.$el.appendChild(e);
26+
}
27+
},
28+
},
29+
render () {
30+
return (
31+
<div id="carbon-ads"/>
32+
);
33+
},
34+
};
35+
</script>
36+
<style>
37+
#carbon-ads {
38+
width: 145px;
39+
position: fixed;
40+
bottom: 10px;
41+
right: 10px;
42+
padding: 10px;
43+
background-color: #fff;
44+
border-radius: 3px;
45+
font-size: 13px;
46+
font-family: "Source Sans Pro", "Helvetica Neue", Arial, sans-serif;
47+
}
48+
#carbon-ads a {
49+
display: inline-block;
50+
color: #7f8c8d;
51+
font-weight: normal;
52+
}
53+
#carbon-ads span {
54+
color: #7f8c8d;
55+
display: inline-block;
56+
margin-bottom: 5px;
57+
}
58+
#carbon-ads img {
59+
width: 125px;
60+
}
61+
#carbon-ads .carbon-img,
62+
#carbon-ads .carbon-text {
63+
display: block;
64+
margin-bottom: 6px;
65+
font-weight: normal;
66+
color: #34495e;
67+
}
68+
#carbon-ads .carbon-text {
69+
display: -webkit-box;
70+
-webkit-box-orient: vertical;
71+
-webkit-line-clamp: 4;
72+
overflow: hidden;
73+
}
74+
#carbon-ads .carbon-poweredby {
75+
color: #aaa ;
76+
font-weight: normal ;
77+
line-height: 1.2 ;
78+
}
79+
</style>

site/components/layout.vue

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { enquireScreen } from 'enquire-js';
33
import AllDemo from '../demo';
44
import Header from './header';
55
import Footer from './footer';
6+
import CarbonAds from './CarbonAds';
67
import Sponsors from './sponsors';
78
import zhCN from 'antd/locale-provider/zh_CN';
89
import enUS from 'antd/locale-provider/default';
910
import sortBy from 'lodash/sortBy';
10-
import axios from 'axios';
1111
import { isZhCN } from '../util';
1212
import { Provider, create } from '../../components/_util/store';
1313
import NProgress from 'nprogress';
@@ -156,24 +156,6 @@ export default {
156156
mountedCallback () {
157157
NProgress.done();
158158
document.documentElement.scrollTop = 0;
159-
try {
160-
const isGithub = location.host.indexOf('github') !== -1;
161-
if(isGithub){
162-
document.getElementById('ad').innerHTML = '';
163-
const src = '//cdn.carbonads.com/carbon.js?serve=CK7DL2JW&placement=vuecomponentgithubio';
164-
const hm = document.createElement('script');
165-
hm.src = src;
166-
hm.id = '_carbonads_js';
167-
const s = document.getElementById('ad');
168-
s.append(hm);
169-
} else {
170-
axios.get('https://api.codefund.app/properties/162/funder.html?template=square')
171-
.then(function (response) {
172-
document.getElementById("codefund").innerHTML = response.data;
173-
});
174-
}
175-
176-
} catch (error) {}
177159
},
178160
},
179161
@@ -320,6 +302,7 @@ export default {
320302
</div>
321303
</a-locale-provider>
322304
{ name.indexOf('back-top') === -1 ? <a-back-top /> : null }
305+
<CarbonAds />
323306
</div>
324307
);
325308
},

site/index.html

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -16,63 +16,6 @@
1616
display: none;
1717
}
1818
</style>
19-
<style>
20-
#ad, #codefund {
21-
width: 145px;
22-
position: fixed;
23-
bottom: 10px;
24-
right: 10px;
25-
padding: 10px;
26-
background-color: #fff;
27-
border-radius: 3px;
28-
font-size: 13px;
29-
font-family: "Source Sans Pro", "Helvetica Neue", Arial, sans-serif;
30-
}
31-
#ad a, #codefund a {
32-
display: inline-block;
33-
color: #7f8c8d;
34-
font-weight: normal;
35-
}
36-
#codefund a {
37-
color: #7f8c8d !important;
38-
font-weight: normal !important;
39-
}
40-
#ad span {
41-
color: #7f8c8d;
42-
display: inline-block;
43-
margin-bottom: 5px;
44-
}
45-
#codefund #cf {
46-
margin-bottom: 0px!important;
47-
border-radius: 0px!important;
48-
}
49-
#ad img {
50-
width: 125px;
51-
}
52-
#ad .carbon-img,
53-
#ad .carbon-text {
54-
display: block;
55-
margin-bottom: 6px;
56-
font-weight: normal;
57-
color: #34495e;
58-
}
59-
#ad .carbon-text,
60-
#codefund .cf-text {
61-
display: -webkit-box!important;
62-
-webkit-box-orient: vertical!important;
63-
-webkit-line-clamp: 4!important;
64-
overflow: hidden!important;
65-
}
66-
#codefund .cf-text {
67-
padding-bottom: 5px !important;
68-
font-size: 12px !important;
69-
}
70-
#ad .carbon-poweredby, #codefund .cf-powered-by {
71-
color: #aaa !important;
72-
font-weight: normal !important;
73-
line-height: 1.2 !important;
74-
}
75-
</style>
7619
<script>
7720
var _hmt = _hmt || [];
7821
var isGithub = location.host.indexOf('github') !== -1;

site/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ const router = new VueRouter({
5151
routes,
5252
});
5353
router.beforeEach((to, from, next) => {
54-
NProgress.start();
54+
if (to.path !== from.path) {
55+
NProgress.start();
56+
}
5557
next();
5658
});
5759
new Vue({

0 commit comments

Comments
 (0)