Commit 88e658ee authored by lei's avatar lei

1111

parent a2d138a9
...@@ -21,7 +21,6 @@ import fullScreen from '@/utils/full' ...@@ -21,7 +21,6 @@ import fullScreen from '@/utils/full'
const serviceUrl = import.meta.env.VITE_VIDEO_URL; const serviceUrl = import.meta.env.VITE_VIDEO_URL;
const apiUrl = import.meta.env.VITE_SERVICE_URL; const apiUrl = import.meta.env.VITE_SERVICE_URL;
const webSocketUrl = import.meta.env.VITE_WEBSOCKET_URL; const webSocketUrl = import.meta.env.VITE_WEBSOCKET_URL;
...@@ -73,10 +72,7 @@ const getCameraList = async () => { ...@@ -73,10 +72,7 @@ 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;
if (cameraList.value.length > 0) { cameraList.value.length > 0 && switchVideoPalyer(cameraList.value[0].id);
cId.value = cameraList.value[0].id; // 设置默认选中ID
switchVideoPalyer(cameraList.value[0].id);
}
} }
}); });
}; };
...@@ -87,7 +83,6 @@ const audioId = ref(''); ...@@ -87,7 +83,6 @@ const audioId = ref('');
const playAudio = async (id: string) => { 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();
// 保留原始逻辑备用 // 保留原始逻辑备用
...@@ -103,6 +98,7 @@ const switchVideoPalyer = (id: string) => { ...@@ -103,6 +98,7 @@ const switchVideoPalyer = (id: string) => {
cId.value = id; cId.value = id;
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://')) { // if (!camera?.cameraAddress?.includes('rtsp://')) {
// return message.error('摄像头流地址格式有误!'); // return message.error('摄像头流地址格式有误!');
...@@ -126,6 +122,7 @@ const switchVideoPalyer = (id: string) => { ...@@ -126,6 +122,7 @@ const switchVideoPalyer = (id: string) => {
} }
); );
} catch (e) { } catch (e) {
console.log("======================================= error", e);
} }
}); });
}; };
...@@ -163,6 +160,7 @@ const options = [ ...@@ -163,6 +160,7 @@ const options = [
} }
]; ];
const handleSelect = (key: string) => { const handleSelect = (key: string) => {
console.log(key);
}; };
// 变更状态 // 变更状态
...@@ -204,6 +202,7 @@ let cLogInfo = reactive({}); ...@@ -204,6 +202,7 @@ let cLogInfo = reactive({});
// 切换视频播放源头 // 切换视频播放源头
const switchVideoPlayer = () => { const switchVideoPlayer = () => {
console.log("switchVideoPlayer ==============", "rtsp://admin:gemho10-7@192.168.0.56:554/h264/ch1/main/av_stream`")
// nextTick(() => { // nextTick(() => {
// try { // try {
// // 临时测试 // // 临时测试
...@@ -282,13 +281,14 @@ onMounted(() => { ...@@ -282,13 +281,14 @@ onMounted(() => {
try { try {
let ws = new WebSocket(`${webSocketUrl}/ws/${localStg.get('id')}`); let ws = new WebSocket(`${webSocketUrl}/ws/${localStg.get('id')}`);
// 应改为(测试用临时方案):
// let ws = new WebSocket(`ws://localhost:9999/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);
...@@ -356,14 +356,15 @@ onMounted(() => { ...@@ -356,14 +356,15 @@ onMounted(() => {
}; };
ws.onclose = function () { ws.onclose = function () {
console.log('WebSocket closed');
}; };
ws.onerror = function (error) { ws.onerror = function (error) {
console.error('WebSocket error:', error); // 检查控制台是否有连接错误 console.error('WebSocket error:', error);
}; };
} catch (e) { } catch (e) {
console.log(e,'error') console.log("error", e)
} }
...@@ -554,7 +555,7 @@ onMounted(() => { ...@@ -554,7 +555,7 @@ onMounted(() => {
<template #header-extra> <template #header-extra>
<div style="width: 200px;"> <div style="width: 200px;">
<NSelect v-model:value="cId" @update:value="val => switchVideoPalyer(val)" placeholder="请选择" label-field="cameraName" <NSelect @update:value="val => switchVideoPalyer(val)" placeholder="请选择" label-field="cameraName"
value-field="id" :options="cameraList"></NSelect> value-field="id" :options="cameraList"></NSelect>
</div> </div>
</template> </template>
......
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