From 2afe5839f9fca07f9e137125585ee97fccee699c Mon Sep 17 00:00:00 2001 From: Developer Date: Wed, 25 Mar 2026 13:20:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=9B=B4=E6=92=AD?= =?UTF-8?q?=E5=B0=8F=E7=AA=97=E6=8C=89=E9=92=AE=E7=82=B9=E5=87=BB=E5=90=8E?= =?UTF-8?q?=E5=B0=8F=E7=AA=97=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit useEffect 依赖 miniRoomId 导致 setLive 触发 clearLive 立即清除状态。 改为仅挂载时运行,用 getState() 读取当前值而非订阅响应式变化。 --- app/live/[roomId].tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/live/[roomId].tsx b/app/live/[roomId].tsx index f0652b8..decdc58 100644 --- a/app/live/[roomId].tsx +++ b/app/live/[roomId].tsx @@ -37,14 +37,15 @@ export default function LiveDetailScreen() { const qualities = stream?.qualities ?? []; const currentQn = stream?.qn ?? 0; - const { roomId: miniRoomId, setLive, clearLive } = useLiveStore(); + const { setLive, clearLive } = useLiveStore(); // 进入该直播间时,若小窗正在播放同一房间,清除小窗避免双播 + // 仅在挂载时运行一次(用 getState 读值,不创建响应式依赖) useEffect(() => { - if (miniRoomId === id) { + if (useLiveStore.getState().roomId === id) { clearLive(); } - }, [id, miniRoomId]); + }, []); const actualRoomId = room?.roomid ?? id; const { danmakus, giftCounts } = useLiveDanmaku(isLive ? actualRoomId : 0);