fix: 修复小窗闭包过期、详情页 loading 卡死、视频播放器性能问题

- 小窗 PanResponder 用 storeRef 替代闭包捕获,修复 roomId/bvid 始终为初始值
- useLiveDetail 用 ref 比对替代 cancelled 标志,防止 fetch 被意外取消
- 详情页 useLayoutEffect 同步清除小窗,BigVideoCard 小窗活跃时跳过播放
- 视频播放器竖屏/全屏互斥渲染,减半解码器占用
- onProgress 节流 + 退出全屏强制恢复播放
This commit is contained in:
Developer
2026-03-25 15:03:49 +08:00
parent 68b8b7d665
commit e3def7d01b
11 changed files with 147 additions and 118 deletions

View File

@@ -19,9 +19,12 @@ export function MiniPlayer() {
const pan = useRef(new Animated.ValueXY()).current;
const isDragging = useRef(false);
// 用 ref 保持最新值,避免 PanResponder 闭包捕获过期的初始值
const storeRef = useRef({ bvid, clearVideo, router });
storeRef.current = { bvid, clearVideo, router };
const panResponder = useRef(
PanResponder.create({
// 从 start 阶段即抢占响应权,确保拖动可靠触发
onStartShouldSetPanResponder: () => true,
onPanResponderGrant: () => {
isDragging.current = false;
@@ -38,16 +41,15 @@ export function MiniPlayer() {
onPanResponderRelease: (evt) => {
pan.flattenOffset();
if (!isDragging.current) {
// 点击:通过坐标判断是关闭还是跳转
const { locationX, locationY } = evt.nativeEvent;
const { bvid: vid, clearVideo: clear, router: r } = storeRef.current;
if (locationX > MINI_W - 28 && locationY < 28) {
clearVideo();
clear();
} else {
router.push(`/video/${bvid}` as any);
r.push(`/video/${vid}` as any);
}
return;
}
// 拖动:吸附到最近边缘
const { width: sw, height: sh } = Dimensions.get('window');
const curX = (pan.x as any)._value;
const curY = (pan.y as any)._value;