From fbf2eccad279285d44c81b4ec0403348869b10eb Mon Sep 17 00:00:00 2001 From: Pine Date: Tue, 18 Aug 2026 06:24:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AF=AD=E9=9F=B3=E6=B0=94=E6=B3=A1?= =?UTF-8?q?=E6=B5=85=E8=93=9D=20+=20=E9=A1=B5=E7=9C=89=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E5=85=A8=E9=83=A8=E8=A7=86=E8=A7=89=E7=8A=B6?= =?UTF-8?q?=E6=80=81=20+=20=E7=AE=80=E5=8C=96=E8=87=AA=E5=8A=A8=E9=97=AE?= =?UTF-8?q?=E5=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - /voice 页右下角气泡文本改浅蓝色(最新 #4cc2ff / 历史 #6fb5ea) - GlobalVision 广播 dpm:vision-status(status/cameraOn/gesture/faces) - 页眉图标四态:默认灰(探索) → 识别中浅蓝(摄像头开/检测/面向) → 手势绿(惊喜) → 异常红 - 自动调用语音助手问候语简化为「您好呀,需要我的帮助吗?」 --- src/components/GlobalVision.jsx | 12 ++++++++++++ src/components/PageHeader.jsx | 18 +++++++++++++++--- src/pages/VoiceAssistant.jsx | 2 +- src/pages/voice-overrides.css | 6 +++--- src/styles/datascreen.css | 18 ++++++++++++++++++ 5 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/components/GlobalVision.jsx b/src/components/GlobalVision.jsx index e66643d..839c5a1 100644 --- a/src/components/GlobalVision.jsx +++ b/src/components/GlobalVision.jsx @@ -31,6 +31,18 @@ export default function GlobalVision() { window.dispatchEvent(new CustomEvent('dpm:hand-track', { detail: { hands: vision.hands } })); }, [vision.hands]); + // 视觉识别状态广播:dpm:vision-status(页眉图标展示全部视觉相关状态) + useEffect(() => { + window.dispatchEvent(new CustomEvent('dpm:vision-status', { + detail: { + status: vision.status, // off|loading|detecting|facing|triggered|silent|error + cameraOn: vision.cameraOn, + gesture: vision.gesture, // raise 等最近一次手势 + faces: vision.faces, + }, + })); + }, [vision.status, vision.cameraOn, vision.gesture, vision.faces]); + return ( <> {/* 摄像头驱动(隐藏,仅供全局抽帧识别) */} diff --git a/src/components/PageHeader.jsx b/src/components/PageHeader.jsx index 6db3574..1fc4036 100644 --- a/src/components/PageHeader.jsx +++ b/src/components/PageHeader.jsx @@ -24,6 +24,7 @@ export default function PageHeader() { const [now, setNow] = useState(new Date()); const [aboutOpen, setAboutOpen] = useState(false); const [gestureHit, setGestureHit] = useState(false); // 识别到手势 → 惊喜图标 3s + const [vision, setVision] = useState({ status: 'off', cameraOn: false, gesture: null }); // 视觉识别状态 const pageIdx = usePageIndex(); const gestureTimer = useRef(null); @@ -32,7 +33,7 @@ export default function PageHeader() { return () => clearInterval(iv); }, []); - // 全局手势事件 → 右上角状态图标(默认灰色探索 → 识别到手势变绿色惊喜) + // 全局手势事件 → 惊喜图标 3s useEffect(() => { const onGesture = (e) => { if (!e.detail || !e.detail.type) return; @@ -47,6 +48,17 @@ export default function PageHeader() { }; }, []); + // 视觉识别状态(GlobalVision 广播):off/loading/detecting/facing/triggered/silent/error + useEffect(() => { + const onStatus = (e) => setVision(e.detail || {}); + window.addEventListener('dpm:vision-status', onStatus); + return () => window.removeEventListener('dpm:vision-status', onStatus); + }, []); + + // 图标状态:手势(绿) > 视觉识别中(浅蓝) > 默认(灰) + const visionActive = vision.cameraOn && vision.status !== 'error' && vision.status !== 'off'; + const visionError = vision.status === 'error'; + const dateStr = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`; const week = ['日', '一', '二', '三', '四', '五', '六'][now.getDay()]; const timeStr = now.toLocaleTimeString('zh-CN', { hour12: false }); @@ -101,9 +113,9 @@ export default function PageHeader() { {status}