Commit e6d5c81bd0cb4f99a79dbd68cb72d76ef63ff0ef
Merge branch 'local_dev_latest' into 'main_dev'
perf(src/packages/external/Informations): 单个摄像头,优化加一个loading效果 See merge request yunteng/thingskit-view!205
Showing
3 changed files
with
32 additions
and
12 deletions
... | ... | @@ -103,10 +103,11 @@ const getVideoLists = async (organizationId: string) => { |
103 | 103 | videoOptions.value = res?.data?.map((item: videoListInterface) => { |
104 | 104 | return { |
105 | 105 | label: item.name, |
106 | - value: item.accessMode === AccessMode.Streaming ? item.id : item.accessMode === AccessMode.ManuallyEnter ? item.videoUrl : item?.params?.deviceId, | |
106 | + value: item.accessMode === AccessMode.Streaming ? item.id : item.accessMode === AccessMode.ManuallyEnter ? item.videoUrl : item.id, | |
107 | 107 | id: item.id, |
108 | 108 | accessMode: item.accessMode, |
109 | - channelId: item.accessMode === AccessMode.GBT28181 ? item?.params?.channelNo :'' | |
109 | + channelId: item.accessMode === AccessMode.GBT28181 ? item?.params?.channelNo :'', | |
110 | + deviceId: item.accessMode === AccessMode.GBT28181 ? item?.params?.deviceId :'', | |
110 | 111 | } |
111 | 112 | }) |
112 | 113 | } |
... | ... | @@ -127,8 +128,16 @@ const handleChecked = (value: string) => { |
127 | 128 | } |
128 | 129 | } |
129 | 130 | |
130 | -const handleSelect = async (_: string, e: videoListInterface) => { | |
131 | - const { accessMode, id, value , channelId } = e | |
131 | +const getVideoControlList = async (deviceId: string, channelId: string) => { | |
132 | + const { data: { flv } } = await getVideoControlStart({ | |
133 | + deviceId, | |
134 | + channelId | |
135 | + }) | |
136 | + props.optionData.dataset = flv || '' | |
137 | +} | |
138 | + | |
139 | +const handleSelect = (_: string, e: videoListInterface) => { | |
140 | + const { accessMode, id, value , channelId, deviceId } = e | |
132 | 141 | //流媒体,需要从服务端调取接口换取播放的地址 |
133 | 142 | if (accessMode === AccessMode.Streaming) { |
134 | 143 | getVideoUrlById(id) |
... | ... | @@ -136,12 +145,8 @@ const handleSelect = async (_: string, e: videoListInterface) => { |
136 | 145 | props.optionData.videoId = id |
137 | 146 | } else if (accessMode === AccessMode.GBT28181) { |
138 | 147 | //gbt28181,需要调用接口获取flv播放地址 |
139 | - if(!value) return | |
140 | - const { data: { flv } } = await getVideoControlStart({ | |
141 | - deviceId: value, | |
142 | - channelId | |
143 | - }) | |
144 | - props.optionData.dataset = flv || '' | |
148 | + getVideoControlList(deviceId, channelId) | |
149 | + props.optionData.videoId = id | |
145 | 150 | } else { |
146 | 151 | props.optionData.dataset = value as string |
147 | 152 | } | ... | ... |
1 | 1 | <template> |
2 | 2 | <div> |
3 | - <VideoPlay :baseSize="{ w, h }" :sourceSrc="option.dataset" :autoPlay="option.autoplay" :avatar="option.poster" /> | |
3 | + <n-spin size="medium" :show="showLoading"> | |
4 | + <template #description> | |
5 | + 视频正在努力加载中...... | |
6 | + </template> | |
7 | + <div> | |
8 | + <VideoPlay :baseSize="{ w, h }" :sourceSrc="option.dataset" :autoPlay="option.autoplay" :avatar="option.poster" /> | |
9 | + </div> | |
10 | + </n-spin> | |
4 | 11 | </div> |
5 | 12 | </template> |
6 | 13 | <script setup lang="ts"> |
7 | -import { PropType, toRefs, shallowReactive, watch } from 'vue' | |
14 | +import { PropType, toRefs, shallowReactive, watch, ref } from 'vue' | |
8 | 15 | import { CreateComponentType } from '@/packages/index.d' |
9 | 16 | import { option as configOption } from './config' |
10 | 17 | import { VideoPlay } from './components' |
... | ... | @@ -16,6 +23,8 @@ const props = defineProps({ |
16 | 23 | } |
17 | 24 | }) |
18 | 25 | |
26 | +const showLoading = ref(true) | |
27 | + | |
19 | 28 | const { w, h } = toRefs(props.chartConfig.attr) |
20 | 29 | |
21 | 30 | const { autoplay, dataset, poster } = toRefs(props.chartConfig.option as typeof configOption) |
... | ... | @@ -29,6 +38,11 @@ const option = shallowReactive({ |
29 | 38 | watch( |
30 | 39 | () => dataset?.value, |
31 | 40 | (newData: string) => { |
41 | + if (newData) { | |
42 | + setTimeout(() => { | |
43 | + showLoading.value = false | |
44 | + }, 2000); | |
45 | + } | |
32 | 46 | option.dataset = newData |
33 | 47 | }, |
34 | 48 | { | ... | ... |