mirror of
https://gh-proxy.org/https://github.com/tiajinsha/JKVideo
synced 2026-07-07 23:18:38 +08:00
fix: 修复直播小窗按钮点击后小窗不显示的问题
useEffect 依赖 miniRoomId 导致 setLive 触发 clearLive 立即清除状态。 改为仅挂载时运行,用 getState() 读取当前值而非订阅响应式变化。
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user