Skip to content

Commit 1fd1735

Browse files
committed
update site
1 parent 52b66db commit 1fd1735

File tree

3 files changed

+54
-5
lines changed

3 files changed

+54
-5
lines changed

site/components/GoogleAds.vue

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<script>
2+
export default {
3+
props: {
4+
isMobile: Boolean,
5+
},
6+
watch: {
7+
$route(e, t) {
8+
if (e.path !== t.path && this.$refs.ins && this.$refs.ins.innerHTML) {
9+
this.$nextTick(() => {
10+
this.load();
11+
});
12+
}
13+
},
14+
},
15+
mounted() {
16+
this.load();
17+
},
18+
methods: {
19+
load() {
20+
if (this.scriptDom) {
21+
this.$el.removeChild(this.scriptDom);
22+
}
23+
this.$refs.ins.innerHTML = '';
24+
window.adsbygoogle = undefined;
25+
const e = document.createElement('script');
26+
e.src = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
27+
e.async = true;
28+
this.$el.appendChild(e);
29+
this.scriptDom = e;
30+
(adsbygoogle = window.adsbygoogle || []).push({});
31+
},
32+
},
33+
render() {
34+
return (
35+
<div id="google-ads">
36+
<ins
37+
ref="ins"
38+
class="adsbygoogle"
39+
style="display:block"
40+
data-ad-client="ca-pub-4801326429087140"
41+
data-ad-slot="7647023136"
42+
data-ad-format="auto"
43+
data-full-width-responsive="true"
44+
></ins>
45+
</div>
46+
);
47+
},
48+
};
49+
</script>

site/components/api.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
<template>
22
<div class="markdown api-container">
3+
<GoogleAds />
34
<slot v-if="isZhCN" name="cn" />
45
<slot v-else />
56
</div>
67
</template>
78
<script>
89
import { isZhCN } from '../util';
10+
import GoogleAds from './GoogleAds';
911
export default {
12+
components: {
13+
GoogleAds,
14+
},
1015
name: 'Api',
1116
inject: {
1217
demoContext: { default: {} },

site/index.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@
3737
s.parentNode.insertBefore(hm, s);
3838
})();
3939
</script>
40-
<script
41-
data-ad-client="ca-pub-4801326429087140"
42-
async
43-
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"
44-
></script>
4540
</head>
4641

4742
<body>

0 commit comments

Comments
 (0)