|
|
@ -92,7 +92,6 @@ export default function MeasureAction() { |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 开始/重新测量按钮点击事件
|
|
|
|
const onStart = () => { |
|
|
|
if (startBtnText === "新测量") { |
|
|
@ -168,9 +167,7 @@ export default function MeasureAction() { |
|
|
|
/** ----------------------- WebSocket 消息处理 ----------------------- **/ |
|
|
|
useEffect(() => { |
|
|
|
// 处理任务状态消息
|
|
|
|
const handleStateMessage = (state: MeasureState["data"]) => { |
|
|
|
|
|
|
|
}; |
|
|
|
const handleStateMessage = (state: MeasureState["data"]) => {}; |
|
|
|
|
|
|
|
// 处理事件消息
|
|
|
|
const handleEventMessage = (type: TaskState["data"]) => { |
|
|
@ -236,6 +233,22 @@ export default function MeasureAction() { |
|
|
|
console.error("播放音频时出错:", err); |
|
|
|
}); |
|
|
|
break; |
|
|
|
case "WRONG_SIDE": |
|
|
|
const audio5 = new Audio("/audio/alert_left.mp3"); |
|
|
|
// 播放音频
|
|
|
|
audio5 |
|
|
|
.play() |
|
|
|
.then(() => { |
|
|
|
console.log("音频开始播放"); |
|
|
|
}) |
|
|
|
.catch(err => { |
|
|
|
console.error("播放音频时出错:", err); |
|
|
|
}); |
|
|
|
// 把状态全部置灰
|
|
|
|
updated.forEach(u => (u.color = "h")); |
|
|
|
// 调用重新测量
|
|
|
|
onStart(); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
@ -255,8 +268,8 @@ export default function MeasureAction() { |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const subscription = wsClient.dataOb.subscribe((data) => { |
|
|
|
if ( data.path === "/api/measurement-task/get-task-state") { |
|
|
|
const subscription = wsClient.dataOb.subscribe(data => { |
|
|
|
if (data.path === "/api/measurement-task/get-task-state") { |
|
|
|
handleStateMessage(data.data); |
|
|
|
} else if (data.path === "/api/measurement-task/event") { |
|
|
|
handleEventMessage(data.data); |
|
|
|