From a95034a4db24dfeceb302222eb72c07460bc7223 Mon Sep 17 00:00:00 2001 From: 15945162479 <15945162479@qq.com> Date: Sat, 13 Dec 2025 14:46:13 +0800 Subject: [PATCH] Add File --- src/elderly/components/LogNotification.tsx | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/elderly/components/LogNotification.tsx diff --git a/src/elderly/components/LogNotification.tsx b/src/elderly/components/LogNotification.tsx new file mode 100644 index 0000000..9e74aef --- /dev/null +++ b/src/elderly/components/LogNotification.tsx @@ -0,0 +1,56 @@ +import React, { useEffect, useState } from 'react'; + +interface LogNotificationProps { + message: string | null; + onHide?: () => void; +} + +/** + * Log通知组件 + * 从麦克风按钮向右延伸显示WebSocket log信息 + * 5秒后自动消失 + */ +export const LogNotification: React.FC = ({ message, onHide }) => { + const [isVisible, setIsVisible] = useState(false); + + useEffect(() => { + if (message) { + setIsVisible(true); + + // 5秒后自动隐藏 + const timer = setTimeout(() => { + setIsVisible(false); + setTimeout(() => { + onHide?.(); + }, 300); // 等待淡出动画完成 + }, 5000); + + return () => clearTimeout(timer); + } else { + setIsVisible(false); + } + }, [message, onHide]); + + if (!message) return null; + + return ( +
+
+ {message} +
+
+ ); +};