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
52 lines (50 loc) · 1.26 KB
/
Copy pathSupport.vue
File metadata and controls
52 lines (50 loc) · 1.26 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
<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 () {
window.fetch('https://api.jae.sh/userscript-plus')
.then((r) => {
return r.json()
}).then((json) => {
this.goods = json
this.curIndex = this.random(0,json.length - 1)
})
},
computed: {
showSupportBox () {
return this.goods.length > 0 && Tools.isZH()
}
},
methods: {
random (min, max) {
return (Math.random() * (max - min + 1) | 0) + min
}
}
}
</script>
<style>
.support-box {
height: 28px;
line-height: 28px;
}
.carouse-item {
background-color: #ffffff;
}
</style>