|
@@ -1,50 +1,82 @@
|
|
|
<template>
|
|
|
- <n-button strong secondary type="info" size="large" @click="$router.push('/')" class="back-home-btn">返回首页</n-button>
|
|
|
- <ItemWrap class="contetn_lr-item" title="实时监控">
|
|
|
- <div class="video" ref="videoTest">
|
|
|
- <test-web-h-5 :preId="preId1" ref="h5Player1" />
|
|
|
- <test-web-h-5 :preId="preId2" ref="h5Player2" />
|
|
|
- <el-button type="primary" @click="handlePlay('1')">播放视频一</el-button>
|
|
|
- <el-button type="primary" @click="handlePlay('2')">播放视频二</el-button>
|
|
|
- </div>
|
|
|
-</ItemWrap>
|
|
|
+ <n-button strong secondary type="info" size="large" @click="$router.push('/')" class="back-home-btn">返回首页</n-button>
|
|
|
+ <n-button strong secondary type="info" size="large" @click="changeLayout(1)" class="btn">1x1</n-button>
|
|
|
+ <n-button strong secondary type="info" size="large" @click="changeLayout(2)" class="btn">2x2</n-button>
|
|
|
+ <n-button strong secondary type="info" size="large" @click="changeLayout(3)" class="btn">3x3</n-button>
|
|
|
+ <ItemWrap class="contetn_lr-item" title="实时监控">
|
|
|
+ <div class="grid-container">
|
|
|
+
|
|
|
+ <div class="grid" :style="{ gridTemplateColumns: `repeat(${cols}, 1fr)` }">
|
|
|
+ <div v-for="n in cols * cols" :key="n" class="cell">
|
|
|
+ <webrtc :streamurl="stream_url" ></webrtc>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </ItemWrap>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { ref ,onMounted} from 'vue';
|
|
|
+import { ref, onMounted } from 'vue';
|
|
|
import TestWebH5 from './monitor.vue';
|
|
|
import ItemWrap from '@/components/item-wrap/item-wrap.vue';
|
|
|
|
|
|
-const preId1 = ref('player');
|
|
|
-const preId2 = ref('player2');
|
|
|
-
|
|
|
-const h5Player1 = ref(null);
|
|
|
-const h5Player2 = ref(null);
|
|
|
+const cols = ref(3); // 初始为3列
|
|
|
+let stream_url = ref([
|
|
|
+ {id:1,url:'rtsp://admin:jxzs12345@192.168.1.3:554/h264/ch1/main/av_stream'},
|
|
|
+ {id:2,url:'rtsp://admin:jxzs12345@192.168.1.7:554/h264/ch1/main/av_stream'},
|
|
|
+ {id:3,url:'rtsp://admin:jxzs12345@192.168.1.7:554/h264/ch1/main/av_stream'},
|
|
|
+ {id:4,url:'rtsp://admin:jxzs12345@192.168.1.7:554/h264/ch1/main/av_stream'},
|
|
|
+ {id:5,url:'rtsp://admin:jxzs12345@192.168.1.7:554/h264/ch1/main/av_stream'},
|
|
|
+ {id:6,url:'rtsp://admin:jxzs12345@192.168.1.7:554/h264/ch1/main/av_stream'},
|
|
|
+ {id:7,url:'rtsp://admin:jxzs12345@192.168.1.7:554/h264/ch1/main/av_stream'},
|
|
|
+ {id:8,url:'rtsp://admin:jxzs12345@192.168.1.7:554/h264/ch1/main/av_stream'},
|
|
|
+ {id:9,url:'rtsp://admin:jxzs12345@192.168.1.7:554/h264/ch1/main/av_stream'},
|
|
|
+]);
|
|
|
+const changeLayout = (newCols: number) => {
|
|
|
+ cols.value = newCols;
|
|
|
+};
|
|
|
+</script>
|
|
|
|
|
|
-function handlePlay(val: string) {
|
|
|
- (h5Player1.value as any).play("https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-360p.mp4");
|
|
|
- (h5Player2.value as any).play("ws://视频二地址");
|
|
|
+<style scoped>
|
|
|
+.grid-container {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+ /* 设置全屏 */
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ right: 0;
|
|
|
+ bottom: 0;
|
|
|
}
|
|
|
-onMounted(()=>{
|
|
|
- console.log(h5Player1.value);
|
|
|
-
|
|
|
-})
|
|
|
-</script>
|
|
|
|
|
|
-<style scoped lang="scss">
|
|
|
-.video {
|
|
|
+.grid {
|
|
|
+ display: grid;
|
|
|
+ gap: 10px;
|
|
|
+ margin-top: 20px;
|
|
|
+ /* 占据全屏宽度 */
|
|
|
width: 100%;
|
|
|
- height: 100%;
|
|
|
+ /* 自适应高度 */
|
|
|
+ height: calc(100% - 20px);
|
|
|
}
|
|
|
-.contetn_lr-item{
|
|
|
- height: 1000px;
|
|
|
- font-size: 25px;
|
|
|
+
|
|
|
+.contetn_lr-item {
|
|
|
+ font-size: 25px;
|
|
|
+ height: 900px;
|
|
|
}
|
|
|
-.back-home-btn {
|
|
|
- position: absolute;
|
|
|
- margin-top: 30px;
|
|
|
- top: 10px;
|
|
|
- left: 10px;
|
|
|
+.btn{
|
|
|
+ align-items: center;
|
|
|
+ /* display: flex; */
|
|
|
+ justify-content: center;
|
|
|
+ margin-left: 10px;
|
|
|
+}
|
|
|
+.cell {
|
|
|
+ /* 移除固定宽度 */
|
|
|
+ width: auto;
|
|
|
+ height: 100%;
|
|
|
+ /* 单元格高度自适应 */
|
|
|
+ padding: 10px;
|
|
|
+ text-align: center;
|
|
|
+ border: 1px solid #fff700;
|
|
|
}
|
|
|
-
|
|
|
</style>
|