fix: Canvas标题居中增加offsetY补偿video垂直偏移
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 48s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 52s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m47s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m46s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 1m3s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 2m4s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 1m15s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 2m7s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 1m35s
AI Code Review / AI Code Review (pull_request) Successful in 7m3s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 8m11s
CI/CD Pipeline / CI Gate (pull_request) Successful in 13s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 1m2s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 1m30s
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 987h57m47s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 987h57m48s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 987h57m48s
CI/CD Pipeline / PR Build Worker Image (pull_request) Failing after 988h5m5s
CI/CD Pipeline / PR Build API Image (pull_request) Failing after 988h5m6s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 988h5m56s
CI/CD Pipeline / Canary Release to Production (pull_request) Failing after 987h57m47s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 988h5m56s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 988h6m0s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 987h57m48s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 988h6m0s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 988h5m56s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 988h6m0s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 988h31m5s
CI/CD Pipeline / Integration Tests (pull_request) Failing after 988h31m6s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 988h38m24s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 988h39m16s

This commit is contained in:
2026-08-06 11:21:16 +08:00
parent 55a7cd6088
commit c8ac02759d
@@ -55,6 +55,7 @@ function wrapText(ctx: CanvasRenderingContext2D, text: string, maxWidth: number)
* @param topOffset 顶部/底部偏移量
* @param fontSizeScale 字号缩放(no-video 模式下缩小)
* @param offsetX 绘制区域左边缘相对于 canvas 的偏移(用于 video 居中时补偿 offsetLeft)
* @param offsetY 绘制区域上边缘相对于 canvas 的偏移(用于 video 居中时补偿 offsetTop)
*/
function drawTitleOnCanvas(
ctx: CanvasRenderingContext2D,
@@ -67,6 +68,7 @@ function drawTitleOnCanvas(
topOffset: number,
fontSizeScale = 1,
offsetX = 0,
offsetY = 0,
) {
const dpr = window.devicePixelRatio || 1
const w = canvasWidth
@@ -130,10 +132,10 @@ function drawTitleOnCanvas(
break
}
// 逐行绘制(offsetX 补偿 video 在容器内的居中偏移)
// 逐行绘制(offsetX/offsetY 补偿 video 在容器内的居中偏移)
const x = offsetX + w / 2
lines.forEach((line, i) => {
const y = startY + i * lineHeight
const y = offsetY + startY + i * lineHeight
if (settings.stroke) ctx.strokeText(line, x, y)
ctx.fillText(line, x, y)
})
@@ -208,6 +210,7 @@ export const PreviewVideoPanel: React.FC<PreviewVideoPanelProps> = ({
60,
1,
videoEl ? videoEl.offsetLeft : 0,
videoEl ? videoEl.offsetTop : 0,
)
}, [titleText, titleSettings])