|
|
@@ -79,10 +79,14 @@
|
|
|
<span class="more" @click="handleCheckMore">查看更多 ></span>
|
|
|
</div>
|
|
|
<div class="video">
|
|
|
- <div class="video_box" v-for="(item, index) in 4" :key="index">
|
|
|
- <img
|
|
|
- src="https://materials.cdn.bcebos.com/images/107505592/68889f5dbf4bd8d8ef0cd11f98b5adea.jpeg"
|
|
|
- />
|
|
|
+ <div class="video_box" v-for="(item, index) in videoList" :key="index">
|
|
|
+ <div class="box_mask">无信号</div>
|
|
|
+ <div
|
|
|
+ v-show="item.isShow"
|
|
|
+ class="box_video"
|
|
|
+ :id="index + 'Watch'"
|
|
|
+ ></div>
|
|
|
+ <div class="box_name">{{ item.title }}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -90,7 +94,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { ref, onMounted } from "vue";
|
|
|
+import { ref, onMounted, onUnmounted } from "vue";
|
|
|
import { useRouter } from "vue-router";
|
|
|
import { countUpNum } from "@/utils/countUpNum";
|
|
|
import { reqGetSmartWarning } from "@/api/school/index";
|
|
|
@@ -124,6 +128,40 @@ const currentPage = ref(1);
|
|
|
// 每页多少条
|
|
|
const pageCount = ref(10);
|
|
|
|
|
|
+// 监控列表
|
|
|
+const videoList = ref<any>([
|
|
|
+ {
|
|
|
+ show: false,
|
|
|
+ title: "大门口1",
|
|
|
+ url: "ws://172.16.7.203:8081/1ive/c70_1.1ive.flv",
|
|
|
+ timer: null,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ show: false,
|
|
|
+ title: "大门口2",
|
|
|
+ url: "ws://172.16.7.203:8081/1ive/c68_1.1ive.flv",
|
|
|
+ timer: null,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ show: false,
|
|
|
+ title: "前操场1",
|
|
|
+ url: "ws://172.16.7.203:8081/1ive/c118_1.1ive.flv",
|
|
|
+ timer: null,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ show: false,
|
|
|
+ title: "前操场2",
|
|
|
+ url: "ws://172.16.7.203:8081/1ive/c120_1.1ive.flv",
|
|
|
+ timer: null,
|
|
|
+ },
|
|
|
+]);
|
|
|
+
|
|
|
+// 延时器实例数组
|
|
|
+const timerList = ref<any>([]);
|
|
|
+
|
|
|
+// 监控实例数组
|
|
|
+const playerList = ref<any>([]);
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
// 让数字动起来
|
|
|
getCountUpNum();
|
|
|
@@ -132,7 +170,17 @@ onMounted(() => {
|
|
|
getSmartWarning();
|
|
|
|
|
|
// 登录获取监控权限
|
|
|
- getVideoLogin();
|
|
|
+ // getVideoLogin();
|
|
|
+
|
|
|
+ // 初始化监控
|
|
|
+ initVideo();
|
|
|
+});
|
|
|
+
|
|
|
+onUnmounted(() => {
|
|
|
+ // 销毁WasmPlayer实例
|
|
|
+ destroyVideos();
|
|
|
+ // 销毁延时器实例
|
|
|
+ destroyTimers();
|
|
|
});
|
|
|
|
|
|
// 获取预警推送信息
|
|
|
@@ -157,15 +205,43 @@ const getVideoLogin = async () => {
|
|
|
// });
|
|
|
// console.log(res);
|
|
|
|
|
|
- const res = await axios({
|
|
|
- url: "http://172.16.7.203:8083/av_ja/videoAdmin/login",
|
|
|
- method: "post",
|
|
|
- data: {
|
|
|
- username: "admin",
|
|
|
- password: "admin.123456",
|
|
|
- },
|
|
|
+ // const res = await axios({
|
|
|
+ // url: "http://172.16.7.203:8083/av_ja/videoAdmin/login",
|
|
|
+ // method: "post",
|
|
|
+ // data: {
|
|
|
+ // username: "admin",
|
|
|
+ // password: "admin.123456",
|
|
|
+ // },
|
|
|
+ // });
|
|
|
+ // console.log(res);
|
|
|
+};
|
|
|
+
|
|
|
+const initVideo = () => {
|
|
|
+ videoList.value.forEach((ele: any, index: number) => {
|
|
|
+ let player = new WasmPlayer(null, index + "Watch", (a: any) => {
|
|
|
+ // a表示当前播放的状态
|
|
|
+ if (a === "videoTimestamp") {
|
|
|
+ ele.isShow = true;
|
|
|
+ } else {
|
|
|
+ // 开启一个延时10秒的延时器
|
|
|
+ if (!ele.timer) {
|
|
|
+ (ele.timer as any) = setTimeout(() => {
|
|
|
+ // 如果isShow为false表示播放失败,此时断开连接节约性能
|
|
|
+ if (!ele.isShow) {
|
|
|
+ player.destroy();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 收集延时器实例方便后面销毁
|
|
|
+ timerList.value.push(ele.timer);
|
|
|
+ }, 10000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ player.play(ele.url, 1);
|
|
|
+
|
|
|
+ // 收集监控实例方便后面销毁
|
|
|
+ playerList.value.push(player);
|
|
|
});
|
|
|
- console.log(res);
|
|
|
};
|
|
|
|
|
|
// 查看更多按钮回调
|
|
|
@@ -173,6 +249,20 @@ const handleCheckMore = () => {
|
|
|
router.push("/more");
|
|
|
};
|
|
|
|
|
|
+// 销毁WasmPlayer实例
|
|
|
+const destroyVideos = () => {
|
|
|
+ playerList.value.forEach((ele: any) => {
|
|
|
+ ele.destroy();
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+// 销毁延时器实例
|
|
|
+const destroyTimers = () => {
|
|
|
+ timerList.value.forEach((ele: any) => {
|
|
|
+ clearTimeout(ele);
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
// 让数字动起来
|
|
|
const getCountUpNum = () => {
|
|
|
countUpNum(deviceDom.value, deviceNum.value);
|
|
|
@@ -293,13 +383,38 @@ const getCountUpNum = () => {
|
|
|
height: 320px;
|
|
|
|
|
|
.video_box {
|
|
|
+ position: relative;
|
|
|
width: 198px;
|
|
|
height: 134px;
|
|
|
border-radius: 5px;
|
|
|
|
|
|
- img {
|
|
|
+ .box_mask {
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ font-size: 16px;
|
|
|
+ background-color: #000;
|
|
|
+ }
|
|
|
+
|
|
|
+ .box_video {
|
|
|
+ width: 198px;
|
|
|
+ height: 134px;
|
|
|
+ background-color: rgba($color: #000000, $alpha: 0.3);
|
|
|
+ }
|
|
|
+
|
|
|
+ .box_name {
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ padding-left: 26px;
|
|
|
width: 100%;
|
|
|
- border-radius: 5px;
|
|
|
+ height: 30px;
|
|
|
+ font-size: 16px;
|
|
|
+ background-color: rgba($color: #fff, $alpha: 0.1);
|
|
|
}
|
|
|
}
|
|
|
}
|