From c5f37a9afcfcb4d99967beffd39e9d0928af5124 Mon Sep 17 00:00:00 2001 From: lqtdys Date: Wed, 2 Dec 2026 17:28:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(video):=20=E6=97=8B=E8=BD=AC=E2=87=84?= =?UTF-8?q?=E8=BD=AC=E5=9B=9E=E6=A8=AA=E5=90=91=E6=97=B6=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E9=99=8D=E6=A1=A3=E9=9A=8F=E5=AE=9E=E5=AE=BD=E9=87=8D=E4=BC=B0?= =?UTF-8?q?=EF=BC=88#1844=20=E5=A4=8D=E6=B5=8B=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因:refitForRotation 只清样式 + autoSize(),从不重跑 applyCompact;容器尺寸旋转前后不变(ResizeObserver 不触发),Artplayer autoSize 只 emit autoSize 不 emit resize → compact 档位跨旋转滞留(旋转态窗口 resize 置位缩小档后转回横向,按钮不恢复全尺寸)。两分支末尾统一补跑 applyCompact()。测试:e2e/video-fit.spec.ts 新增旋转降档重估用例(临时注释修复时用例失败,可区分修复前后)。fixes #1844 --- e2e/video-fit.spec.ts | 37 ++++++++++++++++++++++++++ src/components/Content/VideoPlayer.tsx | 6 +++++ 2 files changed, 43 insertions(+) diff --git a/e2e/video-fit.spec.ts b/e2e/video-fit.spec.ts index 9373816f..a30ce739 100644 --- a/e2e/video-fit.spec.ts +++ b/e2e/video-fit.spec.ts @@ -178,3 +178,40 @@ test("旋转 90° 后画面按新方向铺满播放器(#1844)", async ({ pag ) .toBe("fitted"); }); + +test("旋转 ⇄ 转回横向时按钮降档随实宽重估(#1844 复测)", async ({ page }) => { + await openPlayer(page); + + const classes = () => + page.evaluate(() => { + const player = document.querySelector(".art-video-player")!; + return { + compact: player.classList.contains("vp-compact"), + ultra: player.classList.contains("vp-ultra"), + width: Math.round(player.getBoundingClientRect().width), + }; + }); + + // 宽容器(e2e 视口)下两档均不应置位 + const base = await classes(); + expect(base.compact).toBe(false); + expect(base.ultra).toBe(false); + + // 旋转 90°:$player 收窄成纵向框(<560 → vp-ultra) + await rotateFrame(page); + await expect + .poll(async () => (await classes()).ultra, { timeout: 3000 }) + .toBe(true); + + // 转回横向:实宽恢复,两档必须随之清除——滞留即 #1844 复发的 bug + await rotateFrame(page); + await expect + .poll( + async () => { + const c = await classes(); + return !c.compact && !c.ultra ? "restored" : "stale"; + }, + { timeout: 3000 }, + ) + .toBe("restored"); +}); diff --git a/src/components/Content/VideoPlayer.tsx b/src/components/Content/VideoPlayer.tsx index 7874e97d..063c027a 100644 --- a/src/components/Content/VideoPlayer.tsx +++ b/src/components/Content/VideoPlayer.tsx @@ -1788,6 +1788,12 @@ export default function VideoPlayer({ video.style.top = ""; if (!art.fullscreenWeb) art.autoSize(); } + // 旋转过渡改变了 $player 实宽(旋转态收窄成纵向框 / 转回 autoSize 恢复宽框), + // 但容器尺寸不变 → ResizeObserver 不触发,autoSize 只 emit "autoSize" 不 emit + // "resize" → applyCompact 不会被任何路径重跑,档位跨旋转滞留(#1844 复测: + // 旋转态窗口 resize 置位缩小档后转回横向,按钮不恢复全尺寸)。样式写入为同步, + // 此处量到的已是过渡后的布局。 + applyCompact(); }; refitForRotationRef.current = refitForRotation; applyCompact();