forked from jae-jae/Userscript-Plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSupport.vue
More file actions
59 lines (57 loc) · 1.33 KB
/
Copy pathSupport.vue
File metadata and controls
59 lines (57 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<template>
<div class="support-box" v-if="showSupportBox">
<Carousel v-model="curIndex" autoplay loop dots="none" arrow="never" :autoplay-speed="10000">
<a v-for="item in goods" :key="item.url" :href="item.url" target="_blank">
<CarouselItem class="carouse-item">
{{item.title}}
</CarouselItem>
</a>
</Carousel>
</div>
</template>
<script>
import Tools from '../common/js/tools'
export default {
data () {
return {
curIndex: 0,
goods: []
}
},
mounted () {
this.getData()
this.hide()
},
computed: {
showSupportBox () {
return this.goods.length > 0 && Tools.isZH()
}
},
methods: {
getData () {
let api = 'https://gist.githubusercontent.com/jae-jae/addb107b30b12b5d54d2f062bf46e80d/raw/support-userscript-plus.json'
Tools.getJSON(api, (json) => {
this.goods = json
this.curIndex = this.random(0, json.length - 1)
})
},
random (min, max) {
return (Math.random() * (max - min + 1) | 0) + min
},
hide () {
setTimeout(() => {
this.goods = []
}, 10000)
}
}
}
</script>
<style>
.support-box {
height: 28px;
line-height: 28px;
}
.carouse-item {
background-color: #ffffff;
}
</style>