From 4583b4d941d8921bd7332c8b3aaaa1ee96b08aba Mon Sep 17 00:00:00 2001 From: lqtdys Date: Wed, 2 Dec 2026 17:29:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(video):=20=E7=BC=A9=E7=95=A5=E5=9B=BE?= =?UTF-8?q?=E9=94=9A=E5=AE=9A=E5=8F=AF=E8=A7=81=E8=BF=9B=E5=BA=A6=E8=BD=A8?= =?UTF-8?q?=E9=81=93=EF=BC=8C=E9=97=B4=E8=B7=9D=E7=BA=A6=E5=87=8F=E5=8D=8A?= =?UTF-8?q?=EF=BC=88#1953=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 根因:弹层定位量的是 .art-progress 外壳顶(含 10px 上内边距 + 6px 控件行 + 5px 下内边距,3px 可见轨道居中其中,外壳顶比轨道顶高 ~11.5px),弹层底边悬在可见线上方 ~19.5px;#1962 删时间行前由时间行占位遮掩,删行后裸露。锚点改为可见轨道 .art-control-progress-inner 顶 +9px(清 16px 指示圆点上探 6.5px 后留 2.5px),间距约减半且不遮挡圆点。既有 thumb 测试的 gap 基准同步改轨道(否则与修复自相矛盾),另新增贴近轨道用例。fixes #1953 --- e2e/video-controls.spec.ts | 34 ++++++++++++++++++++++++-- src/components/Content/VideoPlayer.tsx | 12 +++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/e2e/video-controls.spec.ts b/e2e/video-controls.spec.ts index 34458854..714dbc28 100644 --- a/e2e/video-controls.spec.ts +++ b/e2e/video-controls.spec.ts @@ -271,8 +271,15 @@ test("进度条悬停显示当前位置缩略图,移开消失", async ({ page const thumb = page.locator('[data-testid="video-thumb"]'); await expect(thumb).toHaveCount(1); const tb = (await thumb.boundingBox())!; - // 缩略图底边紧贴进度条上侧(锚定进度条实际 Y,非写死偏移) - const gap = box.y - (tb.y + tb.height); + // 缩略图底边紧贴可见进度轨道上侧(锚定轨道实际 Y,非写死偏移)。 + // #1953:基准从 .art-progress 外壳改为 .art-control-progress-inner——外壳顶 + // 比轨道顶高 ~11.5px,按外壳量会把悬空误判为贴合。 + const trackBox = await page + .locator(".art-control-progress-inner") + .first() + .boundingBox(); + if (!trackBox) throw new Error("可见进度轨道不可测量"); + const gap = trackBox.y - (tb.y + tb.height); expect(gap).toBeGreaterThanOrEqual(0); expect(gap).toBeLessThanOrEqual(12); // 缩略图显示时,Artplayer 自带的时间气泡隐藏——同屏只留一个时间来源(#1953) @@ -287,6 +294,29 @@ test("进度条悬停显示当前位置缩略图,移开消失", async ({ page await expect(page.locator('[data-testid="video-thumb"]')).toHaveCount(0); }); +test("缩略图底边贴近可见进度轨道(#1953 复测)", async ({ page }) => { + await openMedia(page, "/Users/test/clip.mp4"); + await withRealVideo(page); + const progress = page.locator(".art-progress").first(); + const box = await progress.boundingBox(); + if (!box) throw new Error("进度条不可测量"); + await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2); + const thumb = page.locator('[data-testid="video-thumb"]'); + await expect(thumb).toHaveCount(1); + const tb = (await thumb.boundingBox())!; + // 量可见轨道 .art-control-progress-inner(3px 高),而非 .art-progress 外壳 + // (外壳含 10px 上内边距 + 6px 控件行 + 5px 下内边距,轨道居中其中)。 + // 旧实现按外壳顶定位 → 缩略图底边悬在可见线上方 ~19.5px,必失败。 + const trackBox = await page + .locator(".art-control-progress-inner") + .first() + .boundingBox(); + if (!trackBox) throw new Error("可见进度轨道不可测量"); + const gap = trackBox.y - (tb.y + tb.height); + expect(gap).toBeGreaterThan(0); + expect(gap).toBeLessThanOrEqual(12); +}); + test("全屏态仍有二级菜单", async ({ page }) => { await openMedia(page, "/Users/test/clip.mp4"); await withRealVideo(page); diff --git a/src/components/Content/VideoPlayer.tsx b/src/components/Content/VideoPlayer.tsx index 7874e97d..0a367a58 100644 --- a/src/components/Content/VideoPlayer.tsx +++ b/src/components/Content/VideoPlayer.tsx @@ -1430,7 +1430,15 @@ export default function VideoPlayer({ }; const onProgressMove = (e: MouseEvent) => { if (!progressEl) return; - const rect = progressEl.getBoundingClientRect(); + // #1953:量可见轨道而非 .art-progress 外壳。外壳含 10px 上内边距 + 6px 控件行 + + // 5px 下内边距,3px 轨道居中其中——外壳顶比轨道顶高约 11.5px,旧实现按外壳顶 + // 定位使缩略图底边悬在可见线上方 ~19.5px(#1962 删时间行前被时间行占位遮掩)。 + // 水平方向外壳无内边距,left/width 与轨道一致,故 ratio 与 left 沿用同一 rect。 + // +9 = 6.5px 清指示圆点(16px 圆点上探轨道顶 6.5px)+ 2.5px 余量。 + const trackEl = + progressEl.querySelector(".art-control-progress-inner") ?? + progressEl; + const rect = trackEl.getBoundingClientRect(); const cr = (rootRef.current ?? container).getBoundingClientRect(); const ratio = Math.min( 1, @@ -1439,7 +1447,7 @@ export default function VideoPlayer({ const t = ratio * (art.duration || 0); setThumb({ left: rect.left - cr.left + ratio * rect.width, - bottom: cr.bottom - rect.top + 8, + bottom: cr.bottom - rect.top + 9, t, }); if (Date.now() - lastThumbAt < 120) return;