Commit d3e66a31e31149e072d87079affd28f85985f8a0

Authored by fengwotao
1 parent 2325b748

perf(external/Composes): 摄像头新增视频标题

... ... @@ -15,6 +15,12 @@ const props = defineProps({
15 15 sourceSrc: {
16 16 type: String
17 17 },
  18 + name: {
  19 + type: String
  20 + },
  21 + avatar: {
  22 + type: String
  23 + },
18 24 w: {
19 25 type: Number,
20 26 default: 300
... ... @@ -41,7 +47,8 @@ const options: VideoJsPlayerOptions = {
41 47 preload: 'auto', // 预加载
42 48 autoplay: true, // 是否自动播放
43 49 fluid: false, // 自适应宽高
44   - src: props.sourceSrc, // 要嵌入的视频源的源 URL
  50 + poster: props?.avatar || '',
  51 + src: props?.sourceSrc || '', // 要嵌入的视频源的源 URL
45 52 muted: true,
46 53 userActions: {
47 54 hotkeys: true
... ...
... ... @@ -2,7 +2,17 @@
2 2 <div class="banner-box" ref="root">
3 3 <div class="wrapper">
4 4 <div v-for="(item, index) in option.dataset" :key="index + item" :class="item.className" :style="item.sty">
5   - <CameraItem ref="cameraRef" :key="item + index" :sourceSrc="item.url" :w="w" :h="h" :index="index" />
  5 + <CameraItem
  6 + ref="cameraRef"
  7 + :name="item.name"
  8 + :avatar="item.avatar"
  9 + :key="item + index"
  10 + :sourceSrc="item.url"
  11 + :w="w"
  12 + :h="h"
  13 + :index="index"
  14 + />
  15 + <span class="video-title">{{ item.name }}</span>
6 16 </div>
7 17 </div>
8 18 <a href="javascript:;" class="left" @click="changeSlide('left')"></a>
... ... @@ -37,46 +47,48 @@ let interval = ref(4000)
37 47
38 48 const computedFunc = (initial: number, source: any) => {
39 49 if (initial < 0) initial = 0
40   - let len = source.length,
41   - temp1 = initial - 2 < 0 ? initial - 2 + len : initial - 2,
42   - temp2 = initial - 1 < 0 ? initial - 1 + len : initial - 1,
43   - temp3 = initial,
44   - temp4 = initial + 1 >= len ? initial + 1 - len : initial + 1,
45   - temp5 = initial + 2 >= len ? initial + 2 - len : initial + 2
46   - return source.map((item: any, index: number) => {
47   - let transform = `translate(-50%, -50%) scale(0.7)`,
48   - zIndex = 0,
49   - className = 'slide'
50   - switch (index) {
51   - case temp3:
52   - transform = `translate(-50%, -50%) scale(1)`
53   - className = ['slide', 'activate'] as any
54   - zIndex = 3
55   - break
56   - case temp1:
57   - transform = `translate(-80%, -50%) scale(0.7)`
58   - zIndex = 1
59   - break
60   - case temp5:
61   - transform = `translate(100%, -50%) scale(0.7)`
62   - zIndex = 1
63   - break
64   - case temp2:
65   - transform = `translate(-100%, -50%) scale(0.85)`
66   - zIndex = 2
67   - break
68   - case temp4:
69   - transform = `translate(58%, -50%) scale(0.85)`
70   - zIndex = 2
71   - break
72   - }
73   - item.sty = {
74   - transform,
75   - zIndex
76   - }
77   - item.className = className
78   - return item
79   - })
  50 + if (Array.isArray(source)) {
  51 + let len = source.length,
  52 + temp1 = initial - 2 < 0 ? initial - 2 + len : initial - 2,
  53 + temp2 = initial - 1 < 0 ? initial - 1 + len : initial - 1,
  54 + temp3 = initial,
  55 + temp4 = initial + 1 >= len ? initial + 1 - len : initial + 1,
  56 + temp5 = initial + 2 >= len ? initial + 2 - len : initial + 2
  57 + return source?.map((item: any, index: number) => {
  58 + let transform = `translate(-50%, -50%) scale(0.7)`,
  59 + zIndex = 0,
  60 + className = 'slide'
  61 + switch (index) {
  62 + case temp3:
  63 + transform = `translate(-50%, -50%) scale(1)`
  64 + className = ['slide', 'activate'] as any
  65 + zIndex = 3
  66 + break
  67 + case temp1:
  68 + transform = `translate(-80%, -50%) scale(0.7)`
  69 + zIndex = 1
  70 + break
  71 + case temp5:
  72 + transform = `translate(100%, -50%) scale(0.7)`
  73 + zIndex = 1
  74 + break
  75 + case temp2:
  76 + transform = `translate(-100%, -50%) scale(0.85)`
  77 + zIndex = 2
  78 + break
  79 + case temp4:
  80 + transform = `translate(58%, -50%) scale(0.85)`
  81 + zIndex = 2
  82 + break
  83 + }
  84 + item.sty = {
  85 + transform,
  86 + zIndex
  87 + }
  88 + item.className = className
  89 + return item
  90 + })
  91 + }
80 92 }
81 93
82 94 watch(
... ... @@ -156,6 +168,15 @@ function changeSlide(dir: string) {
156 168 transform: translate(-50%, -50%);
157 169 transition: 0.5s;
158 170 box-shadow: 0 0 4px black;
  171 + .video-title {
  172 + width: v-bind('w+"px"');
  173 + font-size: 30px;
  174 + color: white;
  175 + position: absolute;
  176 + bottom: 6%;
  177 + left: 10%;
  178 + z-index: 999;
  179 + }
159 180 }
160 181 }
161 182 .arrow {
... ...