Skip to content

Commit cece503

Browse files
committed
add horizontal ad
1 parent 3c6b239 commit cece503

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
s.parentNode.insertBefore(hm, s);
1717
})();
1818
</script>
19+
<script>
20+
window['addAds'] = function(){
21+
let childList = document.getElementsByClassName('gads');
22+
for (let i = 0; i < childList.length; i++) {
23+
(adsbygoogle = window.adsbygoogle || []).push({});
24+
}
25+
}
26+
</script>
1927

2028
</head>
2129
<!-- Google tag (gtag.js) -->

src/components/Index.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
<n-layout-header bordered>
66
<HomeHead @theme-active-change="onThemeActiveChange" :init-theme-active-value="initThemeActiveValue"/>
77
</n-layout-header>
8+
89
<n-layout position="absolute" style="top: 150px; bottom: 64px" :native-scrollbar="false"
910
:content-style="layoutCenterContentStyle">
1011

12+
<HorizontalAdUnit />
1113
<n-collapse :default-expanded-names="[...collapseActions]" @item-header-click="handleItemHeaderClick">
1214
<n-card embedded :bordered="false">
1315
<n-collapse-item name="KDoc">
@@ -58,7 +60,6 @@
5860
</n-card>
5961
</n-collapse>
6062

61-
6263
</n-layout>
6364
<n-layout-footer
6465
bordered
@@ -95,6 +96,7 @@ import {BookOutline, HeartOutline} from '@vicons/ionicons5'
9596
import {Icon} from "@vicons/utils";
9697
import HomeFooter from "./HomeFooter.vue";
9798
import ShowCards from "./show/ShowCards.vue";
99+
import HorizontalAdUnit from "./ad/HorizontalAdUnit.vue";
98100
99101
const layoutCenterContentStyle = reactive({
100102
'padding-left': '50px',
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<script setup>
2+
import {onMounted} from "vue";
3+
4+
onMounted(() => {
5+
try {
6+
window.addAds()
7+
console.log('Ads HorizontalAdUnit loaded')
8+
} catch (e) {
9+
console.log(e)
10+
}
11+
})
12+
13+
</script>
14+
15+
<!-- 横向展示广告单元 -->
16+
<template>
17+
<!-- 横向展示广告 -->
18+
<ins class="adsbygoogle"
19+
style="display:block"
20+
data-ad-client="ca-pub-4062299174917944"
21+
data-ad-slot="5610367324"
22+
data-ad-format="auto"
23+
data-full-width-responsive="true"></ins>
24+
</template>

0 commit comments

Comments
 (0)