videoModal.vue
1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<template>
<BasicModal
v-bind="$attrs"
width="60rem"
destroyOnClose
:height="800"
@register="register"
:title="t('deviceManagement.device.videoChannel.preview')"
:showOkBtn="false"
@cancel="handleCancel"
>
<div class="flex items-center justify-center w-full h-full min-h-96 video-container bg-dark-50">
<VideoPlayer :play-url="playUrl" :options="options" />
</div>
</BasicModal>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import VideoPlayer from './video.vue';
import { VideoCancelModalParamsType } from '/@/views/device/list/cpns/tabs/VideoChannel/config';
import { useI18n } from '/@/hooks/web/useI18n';
const emit = defineEmits(['reloadTable', 'register']);
const { t } = useI18n();
const playUrl = ref<Nullable<string>>();
const options = ref<Nullable<VideoCancelModalParamsType>>();
const [register, { setModalProps }] = useModalInner(
async (data: ModalParamsType<VideoCancelModalParamsType>) => {
const { record } = data;
try {
playUrl.value = null;
options.value = null;
setModalProps({
loading: true,
loadingTip: t('deviceManagement.device.videoChannel.videoLoadding'),
});
const { url, type, withToken } = await record.getPlayUrl();
playUrl.value = url;
options.value = record;
options.value.playerProps = {
...(options.value?.playerProps || {}),
streamType: type,
withToken: withToken,
};
} catch (error) {
} finally {
setModalProps({ loading: false });
}
}
);
const handleCancel = () => {
emit('reloadTable');
};
</script>