From df751d889379e025237eb51e7764fa69e886f4a9 Mon Sep 17 00:00:00 2001
From: wangfei <3597712270@qq.com>
Date: 星期二, 20 八月 2024 10:18:10 +0800
Subject: [PATCH] 掰片/识别、钢化模块点击弹出时玻璃变色提示
---
UI-Project/src/views/Identify/identify.vue | 83 +++++++++++++++++++++++++++++++----------
1 files changed, 62 insertions(+), 21 deletions(-)
diff --git a/UI-Project/src/views/Identify/identify.vue b/UI-Project/src/views/Identify/identify.vue
index d71f75c..cfac9d0 100644
--- a/UI-Project/src/views/Identify/identify.vue
+++ b/UI-Project/src/views/Identify/identify.vue
@@ -215,33 +215,74 @@
}
});
}
+// const connectWebSocket = () => {
+// if (!webSocket) {
+// const socketUrl = `ws://${WebSocketHost}:${host}/api/cacheGlass/api/talk/cacheGlass`;
+// webSocket = new WebSocket(socketUrl);
+// webSocket.onmessage = (event) => {
+// const data = JSON.parse(event.data);
+// const scaleFactor = 1621.78/6000;
+// adjustedRects.value = data.currentCutTerritory[0].map(rect => ({
+// ...rect,
+// x_axis: (6000 -(rect.x_axis + rect.width)) * scaleFactor,
+// y_axis: rect.y_axis * 0.17,
+// width: rect.width * scaleFactor ,
+// widtha: rect.width ,
+// heighta: rect.height ,
+// height: rect.height * 0.165 ,
+// glass_state: rect.glass_state,
+// isActive: false
+// }));
+// };
+// webSocket.onerror = (error) => {
+// console.error('WebSocket Error:', error);
+// };
+// webSocket.onclose = () => {
+// console.log('WebSocket Connection Closed');
+// // 鍙互閫夋嫨閲嶆柊杩炴帴
+// };
+// }
+// };
const connectWebSocket = () => {
if (!webSocket) {
const socketUrl = `ws://${WebSocketHost}:${host}/api/cacheGlass/api/talk/cacheGlass`;
webSocket = new WebSocket(socketUrl);
webSocket.onmessage = (event) => {
- const data = JSON.parse(event.data);
- const scaleFactor = 1621.78/6000;
- adjustedRects.value = data.currentCutTerritory[0].map(rect => ({
- ...rect,
- x_axis: (6000 -(rect.x_axis + rect.width)) * scaleFactor,
- y_axis: rect.y_axis * 0.17,
- width: rect.width * scaleFactor ,
- widtha: rect.width ,
- heighta: rect.height ,
- height: rect.height * 0.165 ,
- glass_state: rect.glass_state,
- isActive: false
- }));
+ const data = JSON.parse(event.data);
+ const scaleFactor = 1621.78 / 6000;
+ const newRects = data.currentCutTerritory[0].map(rect => {
+ const existingRect = adjustedRects.value.find(r => r.glass_id === rect.glass_id);
+ if (existingRect) {
+ return {
+ ...existingRect,
+ x_axis: (6000 - (rect.x_axis + rect.width)) * scaleFactor,
+ y_axis: rect.y_axis * 0.17,
+ width: rect.width * scaleFactor,
+ height: rect.height * 0.165,
+ widtha: rect.width,
+ heighta: rect.height,
+ glass_state: rect.glass_state,
+ // 淇濇寔 isActive 鐘舵�佷笉鍙�
+ };
+ } else {
+ // 濡傛灉涓嶅瓨鍦紝鍒欐坊鍔犳柊鐭╁舰锛岄粯璁� isActive 涓� false
+ return {
+ ...rect,
+ x_axis: (6000 - (rect.x_axis + rect.width)) * scaleFactor,
+ y_axis: rect.y_axis * 0.17,
+ width: rect.width * scaleFactor,
+ height: rect.height * 0.165,
+ widtha: rect.width,
+ heighta: rect.height,
+ glass_state: rect.glass_state,
+ isActive: false,
+ glass_id: rect.glass_id,
+ };
+ }
+ });
+ adjustedRects.value = newRects;
};
- webSocket.onerror = (error) => {
- console.error('WebSocket Error:', error);
- };
- webSocket.onclose = () => {
- console.log('WebSocket Connection Closed');
- // 鍙互閫夋嫨閲嶆柊杩炴帴
- };
- }
+ }
};
onMounted(() => {
--
Gitblit v1.8.0