feat(mqtt): 集中式 MQTT 调度器(页面级操作 + vision 开关 + 页面上报)
useMqttControl 扩展命令分发(opc/display/command): - vision_set:全局人物识别开/关(dpm:vision-control → 语音页 visionEnabled) - ai_input / ai_preset / ai_company / ai_zone:AI 助手页操作(dpm:ai-action) - voice_start / voice_stop / voice_refresh:语音对话页操作(dpm:voice-control) - 页面状态即时上报 opc/frontend/state(路由变化即发,心跳外补充) 页面监听: - AiChatPanel:输入并发送 / 选择预设问题发送 - ParkSidePanel:切换分区(加速区/国际区/成长区)/ 切换展示企业(next/prev) - VoiceAssistant:启动/关闭对话 / 刷新页面;vision 全局开关 - MediaScreen:play/pause/next/prev 已有覆盖 切页(navigate/navigate_rel)、心跳上报沿用既有通道。
This commit is contained in:
@@ -114,6 +114,8 @@ export default function VoiceAssistant() {
|
||||
const [messages, setMessages] = useState([]);
|
||||
const [muted, setMuted] = useState(false);
|
||||
const [errorMsg, setErrorMsg] = useState('');
|
||||
// 全局人物识别开关(MQTT vision_set 控制)
|
||||
const [visionEnabled, setVisionEnabled] = useState(true);
|
||||
// 园区数据(页脚概览条;后端 /api/dashboard/snapshot,离线本地模拟兜底)
|
||||
const d = useParkSim();
|
||||
|
||||
@@ -413,7 +415,31 @@ export default function VoiceAssistant() {
|
||||
const visionTriggerRef = useRef(null);
|
||||
const gestureRef = useRef(null);
|
||||
|
||||
// MQTT 调度器 → 语音页操作:启动/关闭对话、刷新页面
|
||||
useEffect(() => {
|
||||
const onVoice = (e) => {
|
||||
const { action } = e.detail || {};
|
||||
if (action === 'start') {
|
||||
if (!clientRef.current) void start();
|
||||
} else if (action === 'stop') {
|
||||
void stop();
|
||||
} else if (action === 'refresh') {
|
||||
window.location.reload();
|
||||
}
|
||||
};
|
||||
window.addEventListener('dpm:voice-control', onVoice);
|
||||
return () => window.removeEventListener('dpm:voice-control', onVoice);
|
||||
}, [start, stop]);
|
||||
|
||||
// MQTT 调度器 → 全局人物识别开关
|
||||
useEffect(() => {
|
||||
const onVision = (e) => setVisionEnabled(Boolean(e.detail?.enabled));
|
||||
window.addEventListener('dpm:vision-control', onVision);
|
||||
return () => window.removeEventListener('dpm:vision-control', onVision);
|
||||
}, []);
|
||||
|
||||
const vision = useVisionDetection({
|
||||
enabled: visionEnabled,
|
||||
onTrigger: () => visionTriggerRef.current?.(),
|
||||
onGesture: (g) => gestureRef.current?.(g),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user