@@ -52,6 +52,7 @@ export function CaptionOverlay() {
5252 const [ style , setStyle ] = useState < CaptionStyle > ( defaultStyle )
5353 const [ isDraggable , setIsDraggable ] = useState ( false )
5454 const [ isDragging , setIsDragging ] = useState ( false )
55+ const [ isInteractive , setIsInteractive ] = useState ( false )
5556 const [ isHoverLocal , setIsHoverLocal ] = useState ( false )
5657 const containerRef = useRef < HTMLDivElement > ( null )
5758 const contentRef = useRef < HTMLDivElement > ( null )
@@ -123,6 +124,20 @@ export function CaptionOverlay() {
123124 return cleanup
124125 } , [ ] )
125126
127+ // 监听交互状态变化(主进程检测鼠标命中字幕窗口)
128+ useEffect ( ( ) => {
129+ if ( ! window . electronAPI ?. onCaptionInteractiveChanged ) return
130+
131+ const cleanup = window . electronAPI . onCaptionInteractiveChanged ( ( interactive ) => {
132+ setIsInteractive ( interactive )
133+ if ( ! interactive ) {
134+ setIsHoverLocal ( false )
135+ }
136+ } )
137+
138+ return cleanup
139+ } , [ ] )
140+
126141 // 本地悬停处理,避免依赖轮询事件
127142 const handleMouseEnter = useCallback ( ( ) => {
128143 setIsHoverLocal ( true )
@@ -131,6 +146,7 @@ export function CaptionOverlay() {
131146
132147 const handleMouseLeave = useCallback ( ( ) => {
133148 setIsHoverLocal ( false )
149+ setIsInteractive ( false )
134150 // 不在拖拽时才允许关闭交互
135151 if ( ! isDragging ) {
136152 window . electronAPI ?. captionSetInteractive ?.( false )
@@ -215,7 +231,7 @@ export function CaptionOverlay() {
215231 const showPlaceholder = ! hasContent && ! isDraggable
216232
217233 // 是否显示锁按钮:鼠标悬停时或处于拖拽模式时
218- const showLockButton = isHoverLocal || isDraggable
234+ const showLockButton = isInteractive || isHoverLocal || isDraggable
219235
220236 return (
221237 < div
0 commit comments