Commit c1e04c3f authored by lei's avatar lei

fix:修复首页饼图数据,报警声音

parent b63b47de
...@@ -80,7 +80,7 @@ VITE_VIDEO_URL=ws://192.168.3.248:9999 ...@@ -80,7 +80,7 @@ VITE_VIDEO_URL=ws://192.168.3.248:9999
VITE_SERVICE_URL=http://192.168.3.248:9996 VITE_SERVICE_URL=http://192.168.3.248:9996
# 开发环境 - WebSocket 全局地址 # 开发环境 - WebSocket 全局地址
VITE_WEBSOCKET_URL=ws://192.168.3.248:9999 VITE_WEBSOCKET_URL=ws://192.168.3.248:9996
VITE_OTHER_SERVICE_BASE_URL= `{ VITE_OTHER_SERVICE_BASE_URL= `{
"demo": "http://192.168.3.248:9999" "demo": "http://192.168.3.248:9999"
......
<script setup lang="tsx"> <script setup lang="tsx">
import { computed, ref, onMounted, reactive, nextTick, watch } from 'vue'; import { computed, ref, onMounted, watch, reactive, nextTick } 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, selectDark } from "naive-ui" import { useMessage, NButton, NImage, NSpace, NTag, useNotification, NDropdown, NRow, NCol, NEllipsis } 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';
...@@ -250,11 +250,25 @@ onMounted(() => { ...@@ -250,11 +250,25 @@ onMounted(() => {
getCameraList(); getCameraList();
getCardData(); getCardData();
try { try {
let ws = new WebSocket(`${webSocketUrl}/ws/${localStg.get('id')}`); const ws = new WebSocket(`${webSocketUrl}/ws/${localStg.get('id')}`);
ws.onopen = function () {
// 添加连接状态日志
console.log('WebSocket连接状态:', ws.readyState); // 0=连接中,1=已连接,2=关闭中,3=已关闭
ws.onopen = function() {
console.log('WebSocket连接成功');
ws.send('Hello, Server! ------------------------- '); ws.send('Hello, Server! ------------------------- ');
// 添加心跳检测
setInterval(() => {
if (ws.readyState === WebSocket.OPEN) {
ws.send('PING');
}
}, 30000);
}; };
ws.onmessage = function (event) {
ws.onmessage = function(event) {
console.log('收到原始数据:', 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) {
...@@ -316,7 +330,10 @@ onMounted(() => { ...@@ -316,7 +330,10 @@ onMounted(() => {
}); });
} else { } else {
logInfo.value = data; logInfo.value = data;
showTipModal.value = true; showTipModal.value = true; // 确保状态更新
nextTick(() => {
showTipModal.value = true; // 强制触发视图更新
});
} }
}; };
......
...@@ -15,12 +15,12 @@ const getCardData = async () => { ...@@ -15,12 +15,12 @@ const getCardData = async () => {
updateOptions((opts) => { updateOptions((opts) => {
opts.series[0].data = [ opts.series[0].data = [
{ {
name: `已启动 ${res.data.data[0].count} 个`, name: `已启动 ${res.data.data[1].count} 个`,
value: res.data.data[0].count, value: res.data.data[1].count,
}, },
{ {
name: `已停用 ${res.data.data[1].count} 个`, name: `已停用 ${res.data.data[0].count} 个`,
value: res.data.data[1].count, 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