fix: BUG修改

This commit is contained in:
kun 2024-03-05 19:45:31 +08:00
parent bb1955e42b
commit 828ddce748
2 changed files with 56 additions and 46 deletions

View File

@ -4,70 +4,80 @@
<i>实时数据</i> <i>实时数据</i>
</div> </div>
<div class="tab-select"> <div class="tab-select">
<span :class="activeTab == 0?'active-span':''" @click="changeActive(0)">实时监控</span> <span :class="activeTab == 0 ? 'active-span' : ''" @click="changeActive(0)">实时监控</span>
<span :class="activeTab == 1?'active-span':''" @click="changeActive(1)">3D模型</span> <span :class="activeTab == 1 ? 'active-span' : ''" @click="changeActive(1)">3D模型</span>
</div> </div>
<div class="href-content" v-if="activeTab == 0"> <div class="href-content" v-if="activeTab == 0">
<el-carousel indicator-position="none" height="450px"> <el-carousel indicator-position="none" height="450px">
<el-carousel-item v-for="(item,index) in videoList" :key="index"> <el-carousel-item v-for="(item, index) in videoList" :key="item.id">
<video <div style="width: 100%;height: 100%;">
style="height: 100%; width: 100%" <ckplayerComp
:id="'videoItem' + index" :name="index"
muted :poster="''"
autoplay :deviceIp="`http://${item.account}:${item.password}`"
/> :videoUrls="item.serialNumber"
:autoPlay="true"
></ckplayerComp>
</div>
</el-carousel-item> </el-carousel-item>
</el-carousel> </el-carousel>
</div> </div>
<div class="href-content" v-if="activeTab == 1"> <div class="href-content" v-if="activeTab == 1">
<iframe :src="iframeUrl" frameborder="0" style="width: 100%;height: 100%;"></iframe> <iframe :src="iframeUrl" frameborder="0" style="width: 100%; height: 100%"></iframe>
</div> </div>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { GlobalStore } from "@/stores"; import { GlobalStore } from "@/stores";
import { ref, watch, onMounted, onBeforeUnmount } from "vue"; import { ref, watch, onMounted, getCurrentInstance } from "vue";
import Srs from "@/assets/js/srs.sdk";
import { selectProjectVideoListApi } from "@/api/modules/video"; import { selectProjectVideoListApi } from "@/api/modules/video";
const emits = defineEmits(["openDialog"]) import ckplayerComp from "../videoManagement/ckplayerComp.vue";
const emits = defineEmits(["openDialog"]);
const store = GlobalStore(); const store = GlobalStore();
const rtcPlayer = ref(); const rtcPlayer = ref();
const videoList = ref([] as any); const videoList = ref([] as any);
const activeTab = ref(0) const activeTab = ref(0);
const iframeUrl = ref('http://jxj.zhgdyun.com:8082/bim/rt-video/srs/srs.html') const iframeUrl = ref("http://jxj.zhgdyun.com:8082/bim/rt-video/srs/srs.html");
const getVideoList = async () => { const getVideoList = async () => {
let res: any = await selectProjectVideoListApi({ let res: any = await selectProjectVideoListApi({
projectSn: store.sn, projectSn: store.sn,
all: 1 all: 1
// all=1 // all=1
}); });
videoList.value = res.result.videoList videoList.value = res.result.videoList;
// 使
setTimeout(() => {
// video
var videos = document.getElementsByTagName('video');
// video
for (var i = 0; i < videos.length; i++) {
//
videos[i].style.width = '99.9%';
videos[i].style.height = '99.9%';
}
}, 1000);
}; };
const changeActive = (activeIndex:any) => { const changeActive = (activeIndex: any) => {
activeTab.value = activeIndex; activeTab.value = activeIndex;
iframeUrl.value = activeIndex == 0?'http://jxj.zhgdyun.com:8082/bim/rt-video/srs/srs.html':'http://jxjzw.zhgdyun.com:8082/rt-3dmx' iframeUrl.value =
} activeIndex == 0 ? "http://jxj.zhgdyun.com:8082/bim/rt-video/srs/srs.html" : "http://jxjzw.zhgdyun.com:8082/rt-3dmx";
watch(() => activeTab.value, (newVal) => { };
if(newVal == 0){ // watch(
for (let i = 0; i < videoList.value.length; i++) { // () => activeTab.value,
let player:any = document.getElementById("videoItem" + i); // newVal => {
//使srs.sdk.js // if (newVal == 0) {
rtcPlayer.value = new Srs.SrsRtcWhipWhepAsync(); // getVideoList();
rtcPlayer.value.play(videoList.value[i].videoUrl); // }
// video // },
player.srcObject = rtcPlayer.value.stream; // {
// 使jswebrtc.min.js // immediate: true
// new JSWebrtc.Player(this.url, { video: player, autoplay: true, }); // }
} // );
}
})
onMounted(() => { onMounted(() => {
getVideoList() getVideoList();
}) });
onBeforeUnmount(() => {
rtcPlayer.value?.close();
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -91,25 +101,25 @@ onBeforeUnmount(() => {
margin-right: auto; margin-right: auto;
} }
} }
.tab-select{ .tab-select {
width: 35%; width: 35%;
margin: 0 auto; margin: 0 auto;
margin-top: 20px; margin-top: 20px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
span{ span {
cursor: pointer; cursor: pointer;
color: #7C859C; color: #7c859c;
font-size: 15px; font-size: 15px;
transition: all 0.5s; transition: all 0.5s;
} }
.active-span{ .active-span {
color: #fff; color: #fff;
font-size: 18px; font-size: 18px;
} }
} }
.href-content{ .href-content {
width: 95%; width: 95%;
height: 490px; height: 490px;
margin: 0 auto; margin: 0 auto;

View File

@ -1,7 +1,7 @@
<!--ckplayer 视频播放--> <!--ckplayer 视频播放-->
<template> <template>
<div style="height: 100%"> <div style="width: 100%;height: 100%">
<video :id="'videoItem' + name" controls autoplay style="width: 100%; height: 100%; object-fit: fill" /> <video :id="'videoItem' + name" muted controls autoplay style="width: 100%;height: 100%;object-fit: fill;" />
</div> </div>
</template> </template>