Blame view

src/views/Study/component/preview.vue 1.54 KB
493fa9ed   夏洋涛   feat:转移
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
61
62
63
<template>
  <div class="preview_mask" @click="handlePreviewMask">
    <div class="preview">
      <div class="preview_img" v-if="'png,jpg,jpeg,gif,bmp'.indexOf(previewType)>-1">
        <img :src="previewUrl" @click.stop style="max-width:100%;" alt="">
      </div>
      <div class="preview_video" v-if="'mp4,webm,ogg'.indexOf(previewType)>-1">
        <video :src="previewUrl" controls @click.stop style="max-width:100%;"></video>
      </div>
      <div class="preview_audio" v-if="'wav,mp3,ogg,acc,webm'.indexOf(previewType)>-1">
        <audio :src="previewUrl" controls @click.stop style="max-width:100%;"></audio>
      </div>
    </div>
  </div>
</template>
<script>
import { onMounted, reactive, ref, toRefs } from 'vue'
export default {
  name: 'preview',
  props: {
    previewType: String,
    previewUrl: String
  },
  setup (props, { emit }) {
    const state = reactive({
      previewUrl: props.previewUrl,
      previewType: props.previewType,
    })
    onMounted(() => {
      console.log(props)
      console.log(props.previewType)
    })
    const handlePreviewMask = () => {
      emit('closePreview')
    }
    return {
      ...toRefs(state),
      handlePreviewMask
    }
  }
}
</script>
<style lang="scss">
.preview_mask {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  position: absolute;
  top: 0;
  left: 0;
  z-index: 99;
  font-size: 0;
  .preview {
    max-width: 70%;
    max-height: 70%;
    // background: #fff;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
}
</style>