Commit b63b47de authored by lei's avatar lei

fix:视频分析任务启动状态、监控视频默认第一选项

parent 3ae172f8
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { computed, ref, onMounted, reactive, nextTick, watch } from 'vue'; import { computed, ref, onMounted, reactive, nextTick, watch } from 'vue';
import { useAppStore } from '@/store/modules/app'; import { useAppStore } from '@/store/modules/app';
import { ArrowLeft20Filled } from '@vicons/fluent'; import { ArrowLeft20Filled } from '@vicons/fluent';
import { useMessage, NConfigProvider, darkTheme, NButton, NImage, NSpace, NTag, useNotification, NDropdown, NRow, NCol, NEllipsis } from "naive-ui" import { useMessage, NConfigProvider, darkTheme, NButton, NImage, NSpace, NTag, useNotification, NDropdown, NRow, NCol, NEllipsis, selectDark } from "naive-ui"
import HeaderBanner from './modules/header-banner.vue'; import HeaderBanner from './modules/header-banner.vue';
import CardData from './modules/card-data.vue'; import CardData from './modules/card-data.vue';
import LineChart from './modules/line-chart.vue'; import LineChart from './modules/line-chart.vue';
...@@ -62,6 +62,7 @@ const start = () => { ...@@ -62,6 +62,7 @@ const start = () => {
} }
const cameraList = ref([]); const cameraList = ref([]);
const selectData = ref('');
// 获取区域 // 获取区域
const getCameraList = async () => { const getCameraList = async () => {
const params = { const params = {
...@@ -72,7 +73,10 @@ const getCameraList = async () => { ...@@ -72,7 +73,10 @@ const getCameraList = async () => {
await api_getCameraList(params).then(res => { await api_getCameraList(params).then(res => {
if (res.data.code === 200) { if (res.data.code === 200) {
cameraList.value = res.data.data.records; cameraList.value = res.data.data.records;
cameraList.value.length > 0 && switchVideoPalyer(cameraList.value[0].id); cameraList.value.length > 0 && switchVideoPalyer(cameraList.value[0].id);
selectData.value = cameraList.value[0].cameraName;
} }
}); });
}; };
...@@ -84,7 +88,7 @@ const playAudio = async (id: string) => { ...@@ -84,7 +88,7 @@ const playAudio = async (id: string) => {
// 创建新的音频元素并播放 // 创建新的音频元素并播放
const audio = new Audio(`${apiUrl}/v1/play/${id}`); const audio = new Audio(`${apiUrl}/v1/play/${id}`);
audio.play(); audio.play();
// 保留原始逻辑备用 // 保留原始逻辑备用
// htmlStr.value = `<audio id="aWrap" controls autoplay> // htmlStr.value = `<audio id="aWrap" controls autoplay>
// <source src="${apiUrl}/v1/play/${id}" type="audio/mpeg"> // <source src="${apiUrl}/v1/play/${id}" type="audio/mpeg">
...@@ -92,23 +96,13 @@ const playAudio = async (id: string) => { ...@@ -92,23 +96,13 @@ const playAudio = async (id: string) => {
// nextTick(() => document.getElementById('aWrap')?.play()); // nextTick(() => document.getElementById('aWrap')?.play());
}; };
const cId = ref('');
const cName = ref(''); const cName = ref('');
const switchVideoPalyer = (id: string) => { const switchVideoPalyer = (id: string) => {
cId.value = id; selectData.value = cameraList.value.filter(item => item?.id === id)[0].cameraName;
let camera = cameraList.value.filter(item => item?.id === id)[0]; let camera = cameraList.value.filter(item => item?.id === id)[0];
console.log("======================================= id", id, camera?.cameraAddress);
// if (!camera?.cameraAddress?.includes('rtsp://')) {
// return message.error('摄像头流地址格式有误!');
// }
cName.value = camera.cameraName; cName.value = camera.cameraName;
jsmpeg.value && jsmpeg.value.destroy(); jsmpeg.value && jsmpeg.value.destroy();
nextTick(() => { nextTick(() => {
try { try {
const rtsp1 = camera.cameraAddress; const rtsp1 = camera.cameraAddress;
...@@ -122,7 +116,6 @@ const switchVideoPalyer = (id: string) => { ...@@ -122,7 +116,6 @@ const switchVideoPalyer = (id: string) => {
} }
); );
} catch (e) { } catch (e) {
console.log("======================================= error", e);
} }
}); });
}; };
...@@ -227,9 +220,9 @@ const getCardData = async () => { ...@@ -227,9 +220,9 @@ const getCardData = async () => {
if (res.data.code === 200) { if (res.data.code === 200) {
// devData.value = res.data.data; // devData.value = res.data.data;
(res.data.data).forEach(item => { (res.data.data).forEach(item => {
if(item.status === 0){ if (item.status === 0) {
devData.value.online = item.count devData.value.online = item.count
}else{ } else {
devData.value.offline = item.count devData.value.offline = item.count
} }
}) })
...@@ -249,49 +242,21 @@ const openCamera = (item) => { ...@@ -249,49 +242,21 @@ const openCamera = (item) => {
const full = ref(false); const full = ref(false);
// watch(full, (oldType, curType) => {
// if (curType) {
// nextTick(() => {
// const el = document.getElementById('canvas-4');
// const { clientWidth, clientHeight } = el;
// console.log(clientWidth, clientHeight)
// el.width = clientWidth;
// el.height = clientHeight;
// switchVideoPalyer();
// })
// }
// });
/**
* 窗口自适应
*/
// window.addEventListener('resize', (e) => {
// if (full.value) {
// }
// })
onMounted(() => { onMounted(() => {
getAlarmLog(); getAlarmLog();
getCameraList(); getCameraList();
getCardData(); getCardData();
// =============================================================== Demo | S
try { try {
let ws = new WebSocket(`${webSocketUrl}/ws/${localStg.get('id')}`); let ws = new WebSocket(`${webSocketUrl}/ws/${localStg.get('id')}`);
ws.onopen = function () { ws.onopen = function () {
console.log('WebSocket connected --------------------------------------------------------------------------');
ws.send('Hello, Server! ------------------------- '); ws.send('Hello, Server! ------------------------- ');
}; };
ws.onmessage = function (event) { ws.onmessage = function (event) {
console.log('---------------------- WebSocket received message:', JSON.parse(event.data));
let data = JSON.parse(event.data); let data = JSON.parse(event.data);
data.algorithmId && playAudio(data.algorithmId); data.algorithmId && playAudio(data.algorithmId);
if (data.reminderType === 1) { if (data.reminderType === 1) {
window.$notification?.create({ window.$notification?.create({
duration: 5000, duration: 5000,
...@@ -379,17 +344,10 @@ onMounted(() => { ...@@ -379,17 +344,10 @@ onMounted(() => {
} }
}); });
}); });
</script> </script>
<template> <template>
<div id="HomePage"> <div id="HomePage">
<!-- <canvas height="1080" width="1920" id="canvas-4"></canvas> -->
<!-- =================================== 弹窗 | S --> <!-- =================================== 弹窗 | S -->
<NModal v-model:show="showModal"> <NModal v-model:show="showModal">
<NCard v-if="isDefaultPreview" style="width: 800px;" @close="showModal = false" closable> <NCard v-if="isDefaultPreview" style="width: 800px;" @close="showModal = false" closable>
...@@ -414,8 +372,8 @@ onMounted(() => { ...@@ -414,8 +372,8 @@ onMounted(() => {
<template #icon> <template #icon>
<icon-ic:baseline-slow-motion-video class="text-icon" /> <icon-ic:baseline-slow-motion-video class="text-icon" />
</template> </template>
回放 回放
</NButton> --> </NButton> -->
</NFlex> </NFlex>
</template> </template>
<!-- 图片区域 --> <!-- 图片区域 -->
...@@ -441,7 +399,7 @@ onMounted(() => { ...@@ -441,7 +399,7 @@ onMounted(() => {
switchVideoPlayer(); switchVideoPlayer();
isDefaultPreview = true; isDefaultPreview = true;
} }
"> ">
<NIcon size="25" style="position: relative; top: 2px;"> <NIcon size="25" style="position: relative; top: 2px;">
<ArrowLeft20Filled /> <ArrowLeft20Filled />
</NIcon> </NIcon>
...@@ -555,7 +513,7 @@ onMounted(() => { ...@@ -555,7 +513,7 @@ onMounted(() => {
<template #header-extra> <template #header-extra>
<div style="width: 200px;"> <div style="width: 200px;">
<NSelect @update:value="val => switchVideoPalyer(val)" placeholder="请选择" label-field="cameraName" <NSelect @update:value="val => switchVideoPalyer(val)" :value="selectData" placeholder="请选择" label-field="cameraName"
value-field="id" :options="cameraList"></NSelect> value-field="id" :options="cameraList"></NSelect>
</div> </div>
</template> </template>
......
...@@ -113,8 +113,8 @@ const getCardData = async () => { ...@@ -113,8 +113,8 @@ const getCardData = async () => {
if (res.data.code === 200) { if (res.data.code === 200) {
updateOptions((opts) => { updateOptions((opts) => {
opts.series[0].data = [ opts.series[0].data = [
{ name: `已启动`, value: res.data.data[0].count }, { name: `已启动`, value: res.data.data[1].count },
{ name: `已停用`, value: res.data.data[1].count }, { name: `已停用`, value: res.data.data[0].count },
]; ];
return opts; return opts;
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment