Commit c8b8ec80dc0e4e300e04bc3687b05d9825fc3f5b
1 parent
0a16ecd1
perf(src/packages/external/Informations): 单个摄像头,优化加一个loading效果
Showing
3 changed files
with
32 additions
and
12 deletions
@@ -24,6 +24,7 @@ export interface videoListInterface { | @@ -24,6 +24,7 @@ export interface videoListInterface { | ||
24 | value: string | 24 | value: string |
25 | sn: string | 25 | sn: string |
26 | channelId: string | 26 | channelId: string |
27 | + deviceId: string | ||
27 | params: GBT28181Params | 28 | params: GBT28181Params |
28 | } | 29 | } |
29 | 30 |
@@ -103,10 +103,11 @@ const getVideoLists = async (organizationId: string) => { | @@ -103,10 +103,11 @@ const getVideoLists = async (organizationId: string) => { | ||
103 | videoOptions.value = res?.data?.map((item: videoListInterface) => { | 103 | videoOptions.value = res?.data?.map((item: videoListInterface) => { |
104 | return { | 104 | return { |
105 | label: item.name, | 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 | id: item.id, | 107 | id: item.id, |
108 | accessMode: item.accessMode, | 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,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 | if (accessMode === AccessMode.Streaming) { | 142 | if (accessMode === AccessMode.Streaming) { |
134 | getVideoUrlById(id) | 143 | getVideoUrlById(id) |
@@ -136,12 +145,8 @@ const handleSelect = async (_: string, e: videoListInterface) => { | @@ -136,12 +145,8 @@ const handleSelect = async (_: string, e: videoListInterface) => { | ||
136 | props.optionData.videoId = id | 145 | props.optionData.videoId = id |
137 | } else if (accessMode === AccessMode.GBT28181) { | 146 | } else if (accessMode === AccessMode.GBT28181) { |
138 | //gbt28181,需要调用接口获取flv播放地址 | 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 | } else { | 150 | } else { |
146 | props.optionData.dataset = value as string | 151 | props.optionData.dataset = value as string |
147 | } | 152 | } |
1 | <template> | 1 | <template> |
2 | <div> | 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 | </div> | 11 | </div> |
5 | </template> | 12 | </template> |
6 | <script setup lang="ts"> | 13 | <script setup lang="ts"> |
7 | -import { PropType, toRefs, shallowReactive, watch } from 'vue' | 14 | +import { PropType, toRefs, shallowReactive, watch, ref } from 'vue' |
8 | import { CreateComponentType } from '@/packages/index.d' | 15 | import { CreateComponentType } from '@/packages/index.d' |
9 | import { option as configOption } from './config' | 16 | import { option as configOption } from './config' |
10 | import { VideoPlay } from './components' | 17 | import { VideoPlay } from './components' |
@@ -16,6 +23,8 @@ const props = defineProps({ | @@ -16,6 +23,8 @@ const props = defineProps({ | ||
16 | } | 23 | } |
17 | }) | 24 | }) |
18 | 25 | ||
26 | +const showLoading = ref(true) | ||
27 | + | ||
19 | const { w, h } = toRefs(props.chartConfig.attr) | 28 | const { w, h } = toRefs(props.chartConfig.attr) |
20 | 29 | ||
21 | const { autoplay, dataset, poster } = toRefs(props.chartConfig.option as typeof configOption) | 30 | const { autoplay, dataset, poster } = toRefs(props.chartConfig.option as typeof configOption) |
@@ -29,6 +38,11 @@ const option = shallowReactive({ | @@ -29,6 +38,11 @@ const option = shallowReactive({ | ||
29 | watch( | 38 | watch( |
30 | () => dataset?.value, | 39 | () => dataset?.value, |
31 | (newData: string) => { | 40 | (newData: string) => { |
41 | + if (newData) { | ||
42 | + setTimeout(() => { | ||
43 | + showLoading.value = false | ||
44 | + }, 2000); | ||
45 | + } | ||
32 | option.dataset = newData | 46 | option.dataset = newData |
33 | }, | 47 | }, |
34 | { | 48 | { |