mirror of
https://gh-proxy.org/https://github.com/tiajinsha/JKVideo
synced 2026-07-08 07:28:37 +08:00
fix: 修复小窗闭包过期、详情页 loading 卡死、视频播放器性能问题
- 小窗 PanResponder 用 storeRef 替代闭包捕获,修复 roomId/bvid 始终为初始值 - useLiveDetail 用 ref 比对替代 cancelled 标志,防止 fetch 被意外取消 - 详情页 useLayoutEffect 同步清除小窗,BigVideoCard 小窗活跃时跳过播放 - 视频播放器竖屏/全屏互斥渲染,减半解码器占用 - onProgress 节流 + 退出全屏强制恢复播放
This commit is contained in:
@@ -52,6 +52,10 @@ export function LiveMiniPlayer() {
|
||||
const pan = useRef(new Animated.ValueXY()).current;
|
||||
const isDragging = useRef(false);
|
||||
|
||||
// 用 ref 保持最新值,避免 PanResponder 闭包捕获过期的初始值
|
||||
const storeRef = useRef({ roomId, clearLive, router });
|
||||
storeRef.current = { roomId, clearLive, router };
|
||||
|
||||
const panResponder = useRef(
|
||||
PanResponder.create({
|
||||
onStartShouldSetPanResponder: () => true,
|
||||
@@ -71,10 +75,11 @@ export function LiveMiniPlayer() {
|
||||
pan.flattenOffset();
|
||||
if (!isDragging.current) {
|
||||
const { locationX, locationY } = evt.nativeEvent;
|
||||
const { roomId: rid, clearLive: clear, router: r } = storeRef.current;
|
||||
if (locationX > MINI_W - 28 && locationY < 28) {
|
||||
clearLive();
|
||||
clear();
|
||||
} else {
|
||||
router.push(`/live/${roomId}` as any);
|
||||
r.push(`/live/${rid}` as any);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user