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,7 +12,8 @@ enum Api { | ||
| 12 | BASEORIGINATION = '/organization/me/list/', | 12 | BASEORIGINATION = '/organization/me/list/', |
| 13 | VIDEO = '/video/list', | 13 | VIDEO = '/video/list', |
| 14 | DEVICE_PROFILE = '/device_profile/me/list', | 14 | DEVICE_PROFILE = '/device_profile/me/list', |
| 15 | - DEVICE = '/device' | 15 | + DEVICE = '/device', |
| 16 | + VIDEOURL = '/video/url/' | ||
| 16 | } | 17 | } |
| 17 | 18 | ||
| 18 | export const getDictItemByCode = (value: string) => { | 19 | export const getDictItemByCode = (value: string) => { |
| @@ -99,3 +100,9 @@ export const getDeviceList = (params: any, data?: object) => | @@ -99,3 +100,9 @@ export const getDeviceList = (params: any, data?: object) => | ||
| 99 | params, | 100 | params, |
| 100 | data | 101 | data |
| 101 | }) | 102 | }) |
| 103 | + | ||
| 104 | +//获取平台视频流播放地址 | ||
| 105 | +export const getVideoUrl = (id: string) => | ||
| 106 | + defHttp.get({ | ||
| 107 | + url: `${Api.VIDEOURL}${id}` | ||
| 108 | + }) |
| @@ -11,7 +11,8 @@ export enum sourceTypeEnum { | @@ -11,7 +11,8 @@ export enum sourceTypeEnum { | ||
| 11 | export const option = { | 11 | export const option = { |
| 12 | dataset: [ | 12 | dataset: [ |
| 13 | { | 13 | { |
| 14 | - url: '', | 14 | + byIdUrl: '', //通过接口获取的url |
| 15 | + url: '', //直接获取视频列表的url | ||
| 15 | sourceType: 'custom', | 16 | sourceType: 'custom', |
| 16 | organization: '' | 17 | organization: '' |
| 17 | } | 18 | } |
| @@ -28,13 +28,17 @@ | @@ -28,13 +28,17 @@ | ||
| 28 | key-field="id" | 28 | key-field="id" |
| 29 | children-field="children" | 29 | children-field="children" |
| 30 | :options="originationOption" | 30 | :options="originationOption" |
| 31 | - @update:value="handleUpdateTreeValue($event, item)" | 31 | + @update:value="handleUpdateTreeValue($event)" |
| 32 | /> | 32 | /> |
| 33 | </setting-item> | 33 | </setting-item> |
| 34 | </setting-item-box> | 34 | </setting-item-box> |
| 35 | <setting-item-box v-if="item.sourceType === sourceTypeEnum.PLATFORM" name="视频" :alone="true"> | 35 | <setting-item-box v-if="item.sourceType === sourceTypeEnum.PLATFORM" name="视频" :alone="true"> |
| 36 | <setting-item> | 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 | </setting-item> | 42 | </setting-item> |
| 39 | </setting-item-box> | 43 | </setting-item-box> |
| 40 | <n-button size="small" @click="optionData.dataset.splice(index, 1)"> - </n-button> | 44 | <n-button size="small" @click="optionData.dataset.splice(index, 1)"> - </n-button> |
| @@ -43,7 +47,7 @@ | @@ -43,7 +47,7 @@ | ||
| 43 | style="margin-left: 10px" | 47 | style="margin-left: 10px" |
| 44 | v-if="optionData.dataset.length < 9" | 48 | v-if="optionData.dataset.length < 9" |
| 45 | size="small" | 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 | </n-button> | 53 | </n-button> |
| @@ -54,7 +58,7 @@ | @@ -54,7 +58,7 @@ | ||
| 54 | import { PropType, ref, onMounted } from 'vue' | 58 | import { PropType, ref, onMounted } from 'vue' |
| 55 | import { option, sourceTypeEnum } from './config' | 59 | import { option, sourceTypeEnum } from './config' |
| 56 | import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting' | 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 | import { NTreeSelect } from 'naive-ui' | 62 | import { NTreeSelect } from 'naive-ui' |
| 59 | 63 | ||
| 60 | const props = defineProps({ | 64 | const props = defineProps({ |
| @@ -84,13 +88,18 @@ const getOriginationList = async () => { | @@ -84,13 +88,18 @@ const getOriginationList = async () => { | ||
| 84 | originationOption.value = res | 88 | originationOption.value = res |
| 85 | } | 89 | } |
| 86 | 90 | ||
| 87 | -const handleUpdateTreeValue = (e: any, value: object) => { | 91 | +const handleUpdateTreeValue = (e: any) => { |
| 88 | getVideoLists(e) | 92 | getVideoLists(e) |
| 89 | } | 93 | } |
| 90 | 94 | ||
| 91 | const getVideoLists = async (organizationId: string) => { | 95 | const getVideoLists = async (organizationId: string) => { |
| 92 | const res = await getVideoList({ organizationId }) | 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 | const handleChecked = ({ target }: any, values: object) => { | 105 | const handleChecked = ({ target }: any, values: object) => { |
| @@ -100,6 +109,24 @@ 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 | onMounted(() => { | 130 | onMounted(() => { |
| 104 | props.optionData.dataset.forEach((item: any) => { | 131 | props.optionData.dataset.forEach((item: any) => { |
| 105 | if (item.sourceType === sourceTypeEnum.PLATFORM) { | 132 | if (item.sourceType === sourceTypeEnum.PLATFORM) { |
| 1 | <template> | 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 | <div class="wrapper"> | 3 | <div class="wrapper"> |
| 7 | <div v-for="(item, index) in option.dataset" :key="index + item" :class="item.className" :style="item.sty"> | 4 | <div v-for="(item, index) in option.dataset" :key="index + item" :class="item.className" :style="item.sty"> |
| 8 | <CameraItem | 5 | <CameraItem |
| @@ -10,7 +7,7 @@ | @@ -10,7 +7,7 @@ | ||
| 10 | :name="item.name" | 7 | :name="item.name" |
| 11 | :avatar="item.avatar" | 8 | :avatar="item.avatar" |
| 12 | :key="item + index" | 9 | :key="item + index" |
| 13 | - :sourceSrc="item.url" | 10 | + :sourceSrc="!item.byIdUrl ? item.url : item.byIdUrl" |
| 14 | :w="w" | 11 | :w="w" |
| 15 | :h="h" | 12 | :h="h" |
| 16 | :index="index" | 13 | :index="index" |
| @@ -70,10 +70,14 @@ watch( | @@ -70,10 +70,14 @@ watch( | ||
| 70 | () => props.path, | 70 | () => props.path, |
| 71 | () => { | 71 | () => { |
| 72 | if (props.path && props.autoPlay) { | 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,7 +55,7 @@ | ||
| 55 | </setting-item-box> | 55 | </setting-item-box> |
| 56 | <setting-item-box v-if="optionData.sourceType === sourceTypeEnum.PLATFORM" name="视频" :alone="true"> | 56 | <setting-item-box v-if="optionData.sourceType === sourceTypeEnum.PLATFORM" name="视频" :alone="true"> |
| 57 | <setting-item> | 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 | </setting-item> | 59 | </setting-item> |
| 60 | </setting-item-box> | 60 | </setting-item-box> |
| 61 | <setting-item-box name="自动播放"> | 61 | <setting-item-box name="自动播放"> |
| @@ -75,7 +75,7 @@ import { uploadFile } from '@/api/external/contentSave/content' | @@ -75,7 +75,7 @@ import { uploadFile } from '@/api/external/contentSave/content' | ||
| 75 | import { UploadCustomRequestOptions, NTreeSelect } from 'naive-ui' | 75 | import { UploadCustomRequestOptions, NTreeSelect } from 'naive-ui' |
| 76 | import { backgroundImageSize } from '@/settings/designSetting' | 76 | import { backgroundImageSize } from '@/settings/designSetting' |
| 77 | import { fetchRouteParamsLocation } from '@/utils' | 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 | const props = defineProps({ | 80 | const props = defineProps({ |
| 81 | optionData: { | 81 | optionData: { |
| @@ -113,16 +113,38 @@ const handleUpdateTreeValue = (value: string) => { | @@ -113,16 +113,38 @@ const handleUpdateTreeValue = (value: string) => { | ||
| 113 | 113 | ||
| 114 | const getVideoLists = async (organizationId: string) => { | 114 | const getVideoLists = async (organizationId: string) => { |
| 115 | const res = await getVideoList({ organizationId }) | 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 | const handleChecked = ({ target }: any) => { | 131 | const handleChecked = ({ target }: any) => { |
| 132 | + props.optionData.dataset = '' | ||
| 120 | const { value } = target | 133 | const { value } = target |
| 121 | if (value === sourceTypeEnum.PLATFORM) { | 134 | if (value === sourceTypeEnum.PLATFORM) { |
| 122 | getOriginationList() | 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 | onMounted(() => { | 148 | onMounted(() => { |
| 127 | if (props.optionData.sourceType === sourceTypeEnum.PLATFORM) { | 149 | if (props.optionData.sourceType === sourceTypeEnum.PLATFORM) { |
| 128 | getOriginationList() | 150 | getOriginationList() |
| @@ -18,7 +18,7 @@ const props = defineProps({ | @@ -18,7 +18,7 @@ const props = defineProps({ | ||
| 18 | 18 | ||
| 19 | const { h } = toRefs(props.chartConfig.attr) | 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 | const option = shallowReactive({ | 23 | const option = shallowReactive({ |
| 24 | dataset: configOption.dataset, | 24 | dataset: configOption.dataset, |
| @@ -28,7 +28,11 @@ const option = shallowReactive({ | @@ -28,7 +28,11 @@ const option = shallowReactive({ | ||
| 28 | watch( | 28 | watch( |
| 29 | () => dataset?.value, | 29 | () => dataset?.value, |
| 30 | (newData: string) => { | 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 | immediate: true | 38 | immediate: true |