Browse Source

chore: update ad

Sendya 4 years ago
parent
commit
5d2c9ff879
1 changed files with 39 additions and 91 deletions
  1. 39 91
      src/components/Other/CarbonAds.vue

+ 39 - 91
src/components/Other/CarbonAds.vue

@@ -1,114 +1,62 @@
 <script>
-const carbonUrl = '//cdn.carbonads.com/carbon.js?serve=CK7DL2JW&placement=antdvcom'
+const googleAdsUrl = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'
 export default {
   props: {
     isMobile: Boolean
   },
-  watch: {
-    $route (e, t) {
-      const adId = '#carbonads'
-      // if(isGitee) {
-      //   adId = '#cf';
-      // }
-      if (e.path !== t.path && this.$el.querySelector(adId)) {
-        this.$el.innerHTML = ''
-        this.load()
-      }
-      this.adInterval && clearInterval(this.adInterval)
-      this.adInterval = setInterval(() => {
-        if (!this.$el.querySelector(adId)) {
-          this.$el.innerHTML = ''
-          this.load()
-        }
-      }, 20000)
-    }
-  },
+  // watch: {
+  //   $route (e, t) {
+  //     const adId = '#adsbygoogle'
+  //     // if(isGitee) {
+  //     //   adId = '#cf';
+  //     // }
+  //     if (e.path !== t.path && this.$el.querySelector(adId)) {
+  //       this.$el.innerHTML = ''
+  //       this.load()
+  //     }
+  //     this.adInterval && clearInterval(this.adInterval)
+  //     this.adInterval = setInterval(() => {
+  //       if (!this.$el.querySelector(adId)) {
+  //         this.$el.innerHTML = ''
+  //         this.load()
+  //       }
+  //     }, 20000)
+  //   }
+  // },
   mounted () {
-    this.load()
+    // this.load()
   },
   methods: {
     load () {
-      // if(isGitee) {
-      //   axios.get('https://api.codefund.app/properties/162/funder.html?template=horizontal')
-      //   .then(function (response) {
-      //     document.getElementById("codefund-ads").innerHTML = response.data;
-      //   });
-      // } else
-      if (carbonUrl) {
+      if (googleAdsUrl) {
+        /* eslint-disable */
+        let adsbygoogle = []
         const e = document.createElement('script')
-        e.id = '_carbonads_js'
-        e.src = carbonUrl
+        e.id = '_adsbygoogle_js'
+        e.src = googleAdsUrl
         this.$el.appendChild(e)
+        setTimeout(() => {
+          (adsbygoogle = window.adsbygoogle || []).push({})
+        }, 2000)
       }
     }
   },
   render () {
-    return <div id="carbon-ads" class={this.isMobile ? 'carbon-mobile' : ''} />
+    // return <ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-4801326429087140" data-ad-slot="6929057621" />
+    return <div class="business-pro-ad"><a href="https://store.antdv.com/pro/" target="_blank">(推荐) 企业级商用版 Admin Pro 现已发售,采用 Vue3 + TS 欢迎购买。</a></div>;
   }
 }
 </script>
-<style lang="less">
-#carbon-ads {
-  width: 256px;
-  /* float: right; */
-  margin-top: 75px;
+
+<style lang="less" scoped>
+.business-pro-ad {
   position: fixed;
+  background: rgba(255,255,255,0.25);
   left: 0;
   bottom: 0;
-  padding: 0;
-  overflow: hidden;
-  z-index: 100;
-  background-color: #fff;
-  /* border-radius: 3px; */
-  font-size: 13px;
-  background: #f5f5f5;
-  font-family: 'Source Sans Pro', 'Helvetica Neue', Arial, sans-serif;
-}
-#carbonads {
-  overflow: hidden;
-}
-#carbon-ads a {
-  display: inline-block;
-  color: #7f8c8d;
-  font-weight: normal;
-}
-#carbon-ads span {
-  color: #7f8c8d;
-}
-#carbon-ads img {
-  float: left;
-  padding-right: 10px;
-}
-#carbon-ads .carbon-img,
-#carbon-ads .carbon-text {
-  display: block;
-  font-weight: normal;
-  color: #34495e;
-}
-#carbon-ads .carbon-text {
-  padding-top: 6px;
-  display: -webkit-box;
-  -webkit-box-orient: vertical;
-  -webkit-line-clamp: 4;
-  overflow: hidden;
-}
-#carbon-ads .carbon-poweredby {
-  color: #aaa;
-  font-weight: normal;
-  line-height: 1.2;
-  margin-top: 6px;
-}
-#carbon-ads.carbon-mobile {
-  width: 100%;
-  position: relative;
-  right: 0;
-  bottom: 0;
-  padding: 0;
-  margin-bottom: 15px;
-  margin-top: 5px;
-  .carbon-img {
-    float: left;
-    margin-right: 10px;
-  }
+  padding: 0 12px;
+  height: 48px;
+  width: 258px;
+  z-index: 99;
 }
 </style>