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
60
| <template>
| <image class="image" :src="imgSrc" mode="aspectFill" :disabled="false" :controls='false' @error="imgerror"></image>
| </template>
|
| <script>
| export default {
| props: {
| src: {
| type: String,
| default: ''
| },
| cloudType: {
| type: String,
| default: 'oss'
| },
| },
| data() {
| return {
| imgSrc: ''
| };
| },
| mounted() {
| this.setCloudFunction()
| },
| methods: {
| imgerror(even) {
| this.imgSrc = `https://mp-61599c79-d7ee-4a75-a24b-e5a288da6dd3.cdn.bspapp.com/cloudstorage/887c60f0-27f8-46d1-8769-2c45be0f3d7d.png`
| },
| setCloudFunction() {
| const fileType = this.src.split('.').pop();
| const IMAGE_REGEXP = /(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg|image)/i
| if (IMAGE_REGEXP.test(fileType)) {
| return this.imgSrc = this.src;
| }
|
| switch (this.cloudType){
| case 'oss':
| this.imgSrc = this.src + '?x-oss-process=video/snapshot,t_0,f_jpg'
| break;
| case 'process':
| this.imgSrc = this.src + '?ci-process=snapshot&time=0.01'
| break;
| case 'vframe':
| this.imgSrc = this.src + '?vframe/jpg/offset/0'
| break;
| default:
| this.imgSrc = this.src
| break;
| }
| }
| }
| }
| </script>
|
| <style lang="scss" scoped>
| .image {
| width: 100%;
| height: 100%;
| }
| </style>
|
|