2019-01-17 03:59:21 +00:00
|
|
|
<script>
|
2019-01-26 08:04:32 +00:00
|
|
|
import axios from 'axios';
|
2019-01-17 03:59:21 +00:00
|
|
|
const carbonUrls = {
|
2019-02-01 09:23:00 +00:00
|
|
|
'vuecomponent.github.io': '//cdn.carbonads.com/carbon.js?serve=CK7DL2JW&placement=vuecomponentgithubio',
|
2019-01-17 03:59:21 +00:00
|
|
|
'tangjinzhou.gitee.io':'//cdn.carbonads.com/carbon.js?serve=CK7DL2JN&placement=tangjinzhougiteeio',
|
2019-02-16 09:16:59 +00:00
|
|
|
'ant-design-vue.gitee.io':'//cdn.carbonads.com/carbon.js?serve=CK7DL2JN&placement=antdesignvuegiteeio',
|
|
|
|
'vue.ant.design': '//cdn.carbonads.com/carbon.js?serve=CK7DL2JW&placement=vueantdesign',
|
2019-01-17 03:59:21 +00:00
|
|
|
};
|
2019-02-23 10:53:02 +00:00
|
|
|
const carbonUrl = carbonUrls[location.host] || '//cdn.carbonads.com/carbon.js?serve=CK7DL2JW&placement=vueantdesign';
|
2019-01-17 03:59:21 +00:00
|
|
|
export default {
|
2019-02-16 06:32:46 +00:00
|
|
|
props: {
|
|
|
|
isMobile: Boolean,
|
|
|
|
},
|
2019-01-17 03:59:21 +00:00
|
|
|
watch: {
|
|
|
|
$route(e, t) {
|
2019-01-26 08:04:32 +00:00
|
|
|
let adId = '#carbonads';
|
2019-02-16 06:32:46 +00:00
|
|
|
// if(isGitee) {
|
|
|
|
// adId = '#cf';
|
|
|
|
// }
|
2019-01-26 08:04:32 +00:00
|
|
|
if(e.path !== t.path && this.$el.querySelector(adId)){
|
2019-01-17 03:59:21 +00:00
|
|
|
this.$el.innerHTML = "";
|
|
|
|
this.load();
|
|
|
|
}
|
2019-01-18 02:18:57 +00:00
|
|
|
this.adInterval && clearInterval(this.adInterval);
|
|
|
|
this.adInterval = setInterval(()=>{
|
2019-01-26 08:04:32 +00:00
|
|
|
if(!this.$el.querySelector(adId)){
|
2019-01-18 02:18:57 +00:00
|
|
|
this.$el.innerHTML = "";
|
|
|
|
this.load();
|
|
|
|
}
|
2019-01-19 09:54:15 +00:00
|
|
|
}, 20000);
|
2019-01-26 08:04:32 +00:00
|
|
|
|
2019-01-17 03:59:21 +00:00
|
|
|
},
|
|
|
|
},
|
2019-02-01 09:23:00 +00:00
|
|
|
mounted() {
|
|
|
|
this.load();
|
|
|
|
},
|
2019-01-17 03:59:21 +00:00
|
|
|
methods: {
|
|
|
|
load() {
|
2019-02-16 06:32:46 +00:00
|
|
|
// 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) {
|
2019-01-17 03:59:21 +00:00
|
|
|
const e = document.createElement("script");
|
|
|
|
e.id = "_carbonads_js";
|
|
|
|
e.src = carbonUrl;
|
|
|
|
this.$el.appendChild(e);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
render () {
|
|
|
|
return (
|
2019-02-16 06:32:46 +00:00
|
|
|
<div id="carbon-ads" class={this.isMobile ? 'carbon-mobile':''}/>
|
2019-01-17 03:59:21 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2019-02-16 06:32:46 +00:00
|
|
|
<style lang="less">
|
2019-01-17 03:59:21 +00:00
|
|
|
#carbon-ads {
|
2019-03-18 09:09:41 +00:00
|
|
|
width: 280px;
|
|
|
|
float: right;
|
|
|
|
position: relative;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
|
|
|
padding: 0;
|
2019-02-16 06:32:46 +00:00
|
|
|
overflow: hidden;
|
2019-01-26 08:04:32 +00:00
|
|
|
z-index: 9;
|
2019-01-17 03:59:21 +00:00
|
|
|
background-color: #fff;
|
|
|
|
border-radius: 3px;
|
|
|
|
font-size: 13px;
|
2019-02-16 06:32:46 +00:00
|
|
|
background: #f5f5f5;
|
2019-01-17 03:59:21 +00:00
|
|
|
font-family: "Source Sans Pro", "Helvetica Neue", Arial, sans-serif;
|
|
|
|
}
|
2019-03-18 09:09:41 +00:00
|
|
|
#carbonads {
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
2019-01-17 03:59:21 +00:00
|
|
|
#carbon-ads a {
|
|
|
|
display: inline-block;
|
|
|
|
color: #7f8c8d;
|
|
|
|
font-weight: normal;
|
|
|
|
}
|
|
|
|
#carbon-ads span {
|
|
|
|
color: #7f8c8d;
|
|
|
|
}
|
|
|
|
#carbon-ads img {
|
2019-03-18 09:09:41 +00:00
|
|
|
float: left;
|
|
|
|
margin-right: 10px;
|
2019-01-17 03:59:21 +00:00
|
|
|
}
|
|
|
|
#carbon-ads .carbon-img,
|
|
|
|
#carbon-ads .carbon-text {
|
|
|
|
display: block;
|
|
|
|
font-weight: normal;
|
|
|
|
color: #34495e;
|
|
|
|
}
|
|
|
|
#carbon-ads .carbon-text {
|
2019-03-18 09:09:41 +00:00
|
|
|
padding-top: 6px;
|
2019-01-17 03:59:21 +00:00
|
|
|
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 ;
|
2019-02-16 06:32:46 +00:00
|
|
|
margin-top: 6px;
|
|
|
|
}
|
|
|
|
#carbon-ads.carbon-mobile {
|
|
|
|
width: 100%;
|
|
|
|
position: relative;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
|
|
|
padding: 0;
|
|
|
|
.carbon-img {
|
|
|
|
float: left;
|
|
|
|
margin-right: 10px;
|
|
|
|
}
|
2019-01-17 03:59:21 +00:00
|
|
|
}
|
|
|
|
</style>
|