Commit b27f4f977541d254b809364e85985e0059c17e5e
1 parent
c8eb67f7
feat(src/packages): 信息下的摄像头,修改流媒体获取方式
Showing
8 changed files
with
85 additions
and
22 deletions
... | ... | @@ -12,7 +12,8 @@ enum Api { |
12 | 12 | BASEORIGINATION = '/organization/me/list/', |
13 | 13 | VIDEO = '/video/list', |
14 | 14 | DEVICE_PROFILE = '/device_profile/me/list', |
15 | - DEVICE = '/device' | |
15 | + DEVICE = '/device', | |
16 | + VIDEOURL = '/video/url/' | |
16 | 17 | } |
17 | 18 | |
18 | 19 | export const getDictItemByCode = (value: string) => { |
... | ... | @@ -99,3 +100,9 @@ export const getDeviceList = (params: any, data?: object) => |
99 | 100 | params, |
100 | 101 | data |
101 | 102 | }) |
103 | + | |
104 | +//获取平台视频流播放地址 | |
105 | +export const getVideoUrl = (id: string) => | |
106 | + defHttp.get({ | |
107 | + url: `${Api.VIDEOURL}${id}` | |
108 | + }) | ... | ... |
... | ... | @@ -28,13 +28,17 @@ |
28 | 28 | key-field="id" |
29 | 29 | children-field="children" |
30 | 30 | :options="originationOption" |
31 | - @update:value="handleUpdateTreeValue($event, item)" | |
31 | + @update:value="handleUpdateTreeValue($event)" | |
32 | 32 | /> |
33 | 33 | </setting-item> |
34 | 34 | </setting-item-box> |
35 | 35 | <setting-item-box v-if="item.sourceType === sourceTypeEnum.PLATFORM" name="视频" :alone="true"> |
36 | 36 | <setting-item> |
37 | - <n-select v-model:value="item.url" :options="videoOptions" /> | |
37 | + <n-select | |
38 | + v-model:value="item.url" | |
39 | + @update:value="(value:string,e:any) => handleSelect(value,e, index)" | |
40 | + :options="videoOptions" | |
41 | + /> | |
38 | 42 | </setting-item> |
39 | 43 | </setting-item-box> |
40 | 44 | <n-button size="small" @click="optionData.dataset.splice(index, 1)"> - </n-button> |
... | ... | @@ -43,7 +47,7 @@ |
43 | 47 | style="margin-left: 10px" |
44 | 48 | v-if="optionData.dataset.length < 9" |
45 | 49 | size="small" |
46 | - @click="optionData.dataset.push({ url: '', sourceType: 'custom', organization: '' })" | |
50 | + @click="optionData.dataset.push({ url: '', sourceType: 'custom', organization: '', byIdUrl: '' })" | |
47 | 51 | > |
48 | 52 | + |
49 | 53 | </n-button> |
... | ... | @@ -54,7 +58,7 @@ |
54 | 58 | import { PropType, ref, onMounted } from 'vue' |
55 | 59 | import { option, sourceTypeEnum } from './config' |
56 | 60 | import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting' |
57 | -import { getOrganizationList, getVideoList } from '@/api/external/common/index' | |
61 | +import { getOrganizationList, getVideoList, getVideoUrl } from '@/api/external/common/index' | |
58 | 62 | import { NTreeSelect } from 'naive-ui' |
59 | 63 | |
60 | 64 | const props = defineProps({ |
... | ... | @@ -84,13 +88,18 @@ const getOriginationList = async () => { |
84 | 88 | originationOption.value = res |
85 | 89 | } |
86 | 90 | |
87 | -const handleUpdateTreeValue = (e: any, value: object) => { | |
91 | +const handleUpdateTreeValue = (e: any) => { | |
88 | 92 | getVideoLists(e) |
89 | 93 | } |
90 | 94 | |
91 | 95 | const getVideoLists = async (organizationId: string) => { |
92 | 96 | const res = await getVideoList({ organizationId }) |
93 | - videoOptions.value = res?.data?.map((item: any) => ({ label: item.name, value: item.videoUrl })) | |
97 | + videoOptions.value = res?.data?.map((item: any) => ({ | |
98 | + label: item.name, | |
99 | + value: item.accessMode === 1 ? item.id : item.videoUrl, | |
100 | + id: item.id, | |
101 | + accessMode: item.accessMode | |
102 | + })) | |
94 | 103 | } |
95 | 104 | |
96 | 105 | const handleChecked = ({ target }: any, values: object) => { |
... | ... | @@ -100,6 +109,24 @@ const handleChecked = ({ target }: any, values: object) => { |
100 | 109 | } |
101 | 110 | } |
102 | 111 | |
112 | +const getVideoUrlById = async (e: any, id: string, index: number) => { | |
113 | + const res = await getVideoUrl(id) | |
114 | + if (!res) return | |
115 | + const { url } = res.data | |
116 | + props.optionData.dataset.forEach((item: any, itemIndex: number) => { | |
117 | + if (itemIndex === index) { | |
118 | + item.byIdUrl = url | |
119 | + } | |
120 | + }) | |
121 | +} | |
122 | + | |
123 | +const handleSelect = (value: string, e: any, index: number) => { | |
124 | + const { accessMode, id } = e | |
125 | + if (accessMode === 1) { | |
126 | + getVideoUrlById(e, id, index) | |
127 | + } | |
128 | +} | |
129 | + | |
103 | 130 | onMounted(() => { |
104 | 131 | props.optionData.dataset.forEach((item: any) => { |
105 | 132 | if (item.sourceType === sourceTypeEnum.PLATFORM) { | ... | ... |
1 | 1 | <template> |
2 | - <div | |
3 | - @mouseenter="handleMouseenter" | |
4 | - @mouseleave="handleMouseleave" | |
5 | - class="banner-box" ref="root"> | |
2 | + <div @mouseenter="handleMouseenter" @mouseleave="handleMouseleave" class="banner-box" ref="root"> | |
6 | 3 | <div class="wrapper"> |
7 | 4 | <div v-for="(item, index) in option.dataset" :key="index + item" :class="item.className" :style="item.sty"> |
8 | 5 | <CameraItem |
... | ... | @@ -10,7 +7,7 @@ |
10 | 7 | :name="item.name" |
11 | 8 | :avatar="item.avatar" |
12 | 9 | :key="item + index" |
13 | - :sourceSrc="item.url" | |
10 | + :sourceSrc="!item.byIdUrl ? item.url : item.byIdUrl" | |
14 | 11 | :w="w" |
15 | 12 | :h="h" |
16 | 13 | :index="index" | ... | ... |
... | ... | @@ -70,10 +70,14 @@ watch( |
70 | 70 | () => props.path, |
71 | 71 | () => { |
72 | 72 | if (props.path && props.autoPlay) { |
73 | - player?.pause() | |
74 | - player?.load() | |
75 | - player?.src(props.path) | |
76 | - player?.play() | |
73 | + try { | |
74 | + player?.pause() | |
75 | + player?.load() | |
76 | + player?.src(props.path) | |
77 | + player?.play() | |
78 | + } catch (e) { | |
79 | + console.log(e) | |
80 | + } | |
77 | 81 | } |
78 | 82 | }, |
79 | 83 | { | ... | ... |
... | ... | @@ -55,7 +55,7 @@ |
55 | 55 | </setting-item-box> |
56 | 56 | <setting-item-box v-if="optionData.sourceType === sourceTypeEnum.PLATFORM" name="视频" :alone="true"> |
57 | 57 | <setting-item> |
58 | - <n-select v-model:value="optionData.dataset" :options="videoOptions" /> | |
58 | + <n-select @update:value="handleSelect" v-model:value="optionData.dataset" :options="videoOptions" /> | |
59 | 59 | </setting-item> |
60 | 60 | </setting-item-box> |
61 | 61 | <setting-item-box name="自动播放"> |
... | ... | @@ -75,7 +75,7 @@ import { uploadFile } from '@/api/external/contentSave/content' |
75 | 75 | import { UploadCustomRequestOptions, NTreeSelect } from 'naive-ui' |
76 | 76 | import { backgroundImageSize } from '@/settings/designSetting' |
77 | 77 | import { fetchRouteParamsLocation } from '@/utils' |
78 | -import { getOrganizationList, getVideoList } from '@/api/external/common/index' | |
78 | +import { getOrganizationList, getVideoList, getVideoUrl } from '@/api/external/common/index' | |
79 | 79 | |
80 | 80 | const props = defineProps({ |
81 | 81 | optionData: { |
... | ... | @@ -113,16 +113,38 @@ const handleUpdateTreeValue = (value: string) => { |
113 | 113 | |
114 | 114 | const getVideoLists = async (organizationId: string) => { |
115 | 115 | const res = await getVideoList({ organizationId }) |
116 | - videoOptions.value = res?.data?.map((item: any) => ({ label: item.name, value: item.videoUrl })) | |
116 | + videoOptions.value = res?.data?.map((item: any) => ({ | |
117 | + label: item.name, | |
118 | + value: item.accessMode === 1 ? item.id : item.videoUrl, | |
119 | + id: item.id, | |
120 | + accessMode: item.accessMode | |
121 | + })) | |
122 | +} | |
123 | + | |
124 | +const getVideoUrlById = async (id: string) => { | |
125 | + const res = await getVideoUrl(id) | |
126 | + if (!res) return | |
127 | + const { url } = res.data | |
128 | + props.optionData.url = url | |
117 | 129 | } |
118 | 130 | |
119 | 131 | const handleChecked = ({ target }: any) => { |
132 | + props.optionData.dataset = '' | |
120 | 133 | const { value } = target |
121 | 134 | if (value === sourceTypeEnum.PLATFORM) { |
122 | 135 | getOriginationList() |
123 | 136 | } |
124 | 137 | } |
125 | 138 | |
139 | +const handleSelect = (value: string, e: any) => { | |
140 | + const { accessMode, id } = e | |
141 | + if (accessMode === 1) { | |
142 | + getVideoUrlById(id) | |
143 | + } else { | |
144 | + props.optionData.url = '' | |
145 | + } | |
146 | +} | |
147 | + | |
126 | 148 | onMounted(() => { |
127 | 149 | if (props.optionData.sourceType === sourceTypeEnum.PLATFORM) { |
128 | 150 | getOriginationList() | ... | ... |
... | ... | @@ -18,7 +18,7 @@ const props = defineProps({ |
18 | 18 | |
19 | 19 | const { h } = toRefs(props.chartConfig.attr) |
20 | 20 | |
21 | -const { autoplay, dataset, poster } = toRefs(props.chartConfig.option) | |
21 | +const { autoplay, dataset, poster, url } = toRefs(props.chartConfig.option) | |
22 | 22 | |
23 | 23 | const option = shallowReactive({ |
24 | 24 | dataset: configOption.dataset, |
... | ... | @@ -28,7 +28,11 @@ const option = shallowReactive({ |
28 | 28 | watch( |
29 | 29 | () => dataset?.value, |
30 | 30 | (newData: string) => { |
31 | - option.dataset = newData | |
31 | + if (url.value) { | |
32 | + option.dataset = url.value | |
33 | + } else { | |
34 | + option.dataset = newData | |
35 | + } | |
32 | 36 | }, |
33 | 37 | { |
34 | 38 | immediate: true | ... | ... |