diff --git a/web_page/index.html b/web_page/index.html
index dccfa90..90ea40a 100644
--- a/web_page/index.html
+++ b/web_page/index.html
@@ -325,14 +325,18 @@
ws.onmessage = (event) => {
try {
+ // console.log('收到WebSocket消息:', event.data);
const msg = JSON.parse(event.data);
+ // console.log('解析后的消息对象:', msg);
if (msg.msg_type === 'frame') {
+ // console.log('处理frame类型消息');
if (msg.image_base64) {
liveImage.src = `data:image/jpeg;base64,${msg.image_base64}`;
}
currentDetectedActions = msg.result_type || [];
+ // console.log('检测到的动作:', currentDetectedActions);
if (currentDetectedActions.length > 0) {
const actionText = currentDetectedActions.join(', ');
@@ -358,29 +362,40 @@
if (!existingAlert) {
alerts.push(alertMsg);
+ // console.log('添加新的异常告警:', alertMsg);
+ // console.log('当前alerts数组长度:', alerts.length);
renderMessages();
+ // console.log('渲染消息列表完成');
const alertTypes = alertMsg.result_type.join(', ');
addLog(`检测到异常: ${alertTypes}`, 'warning');
}
- } else if (msg.msg_type === 'take_out') {
- // 处理take_out类型的消息
- const takeOutMsg = {
- msg_type: 'take_out',
- person_name: msg.person_name,
- historical_alert_count: msg.historical_alert_count || 0,
- timestamp: Math.floor(Date.now() / 1000)
- };
-
- alerts.push(takeOutMsg);
- renderMessages();
-
- addLog(`人员带出: ${takeOutMsg.person_name} (历史告警: ${takeOutMsg.historical_alert_count})`, 'warning');
}
+ } else if (msg.msg_type === 'take_out') {
+ // console.log('处理take_out类型消息');
+ // 处理take_out类型的消息
+ const takeOutMsg = {
+ msg_type: 'take_out',
+ person_name: msg.person_name,
+ historical_alert_count: msg.historical_alert_count || 0,
+ timestamp: Math.floor(Date.now() / 1000)
+ };
+
+ // console.log('创建take_out消息对象:', takeOutMsg);
+ alerts.push(takeOutMsg);
+ // console.log('当前alerts数组长度:', alerts.length);
+
+ renderMessages();
+ // console.log('渲染消息列表完成');
+
+ addLog(`人员带出: ${takeOutMsg.person_name} (第${takeOutMsg.historical_alert_count}次)`, 'warning');
+ } else {
+ // console.log('未知的消息类型:', msg.msg_type);
}
} catch (e) {
- console.error('invalid ws message', e);
+ console.error('解析WebSocket消息错误:', e);
+ console.error('原始消息数据:', event.data);
}
};
}