fix(title): 预览区标题样式应用真实模板描边/阴影/背景值
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 2s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1s
CI/CD Pipeline / Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 1m6s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 1m12s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 1m24s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 1m26s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m52s
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Style (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Security (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled

问题:FrontendPreviewPlayer 渲染视频预览标题时,描边宽度/颜色、阴影偏移/模糊/颜色、背景色块都被硬编码(如黑描边2px、固定2px阴影、无背景),选模板后预览文字不显示模板真实样式(例如抖音爆款黄的8px黑描边只显示2px)。

修复:
- FrontendPreviewPlayer 扩展 titleSettings props,接收 strokeWidth/strokeColor/shadowOffsetX/Y/shadowBlur/shadowColor/bgEnabled/bgColor/bgPadding/bgRadius/lineHeight 字段
- 所有描边/阴影/背景值按容器等比缩放后用于 CSS
- CanvasPreviewGrid 传递 titleSettings 时补充上述字段,批量预览同步生效
- 删除不再使用的 titleScale 常量
- 数字人侧 PanelLipsyncPreview 已正确读字段,无需改动
This commit is contained in:
saas-backend-agent
2026-09-23 14:10:42 +08:00
parent 2b4bcefc57
commit 16e20ff63c
2 changed files with 51 additions and 8 deletions
@@ -140,7 +140,19 @@ const CanvasPreviewGrid: React.FC<CanvasPreviewGridProps> = ({
bold: titleSettings.bold,
italic: titleSettings.italic,
stroke: titleSettings.stroke,
strokeWidth: titleSettings.strokeWidth,
strokeColor: titleSettings.strokeColor,
shadow: titleSettings.shadow,
shadowOffsetX: titleSettings.shadowOffsetX,
shadowOffsetY: titleSettings.shadowOffsetY,
shadowBlur: titleSettings.shadowBlur,
shadowColor: titleSettings.shadowColor,
bgEnabled: titleSettings.bgEnabled,
bgColor: titleSettings.bgColor,
bgPadding: titleSettings.bgPadding,
bgRadius: titleSettings.bgRadius,
lineHeight: titleSettings.lineHeight,
maxCharsPerLine: titleSettings.maxCharsPerLine,
posX: titleSettings.posX,
posY: titleSettings.posY,
}}
@@ -36,6 +36,18 @@ interface FrontendPreviewPlayerProps {
italic?: boolean
stroke?: boolean
shadow?: boolean
strokeWidth?: number
strokeColor?: string
shadowOffsetX?: number
shadowOffsetY?: number
shadowBlur?: number
shadowColor?: string
bgEnabled?: boolean
bgColor?: string
bgPadding?: number
bgRadius?: number
lineHeight?: number
maxCharsPerLine?: number
posX?: number | null
posY?: number | null
}
@@ -249,10 +261,25 @@ const FrontendPreviewPlayer: React.FC<FrontendPreviewPlayerProps> = ({
const titleSidePct = (TITLE_MARGIN_SIDE / playRes.width) * 100
const titleTopPct = (TITLE_MARGIN_TOP / playRes.height) * 100
const titleBottomPct = (TITLE_MARGIN_BOTTOM / playRes.height) * 100
const titleScale = containerHeight > 0 ? containerHeight / playRes.height : 1
const titleStrokeWidth = Math.max(1, 2 * titleScale)
const titleShadowBlur = 4 * titleScale
const titleShadowOffset = 2 * titleScale
// 标题缩放到容器:字号 px = (settings.size / playRes.height) * containerHeight
// 描边/阴影:读 titleSettings 真实值,按容器比例缩放
const titleStrokeWidth = Math.max(
1,
((titleSettings?.strokeWidth ?? 4) / playRes.height) * containerHeight,
)
const titleStrokeColor = titleSettings?.strokeColor ?? "#000000"
const titleShadowBlur = ((titleSettings?.shadowBlur ?? 4) / playRes.height) * containerHeight
const titleShadowOffsetX =
((titleSettings?.shadowOffsetX ?? 2) / playRes.height) * containerHeight
const titleShadowOffsetY =
((titleSettings?.shadowOffsetY ?? 2) / playRes.height) * containerHeight
const titleShadowColor = titleSettings?.shadowColor ?? "rgba(0,0,0,0.8)"
const titleShadowStr = `${titleShadowOffsetX}px ${titleShadowOffsetY}px ${titleShadowBlur}px ${titleShadowColor}`
// 标题背景色块
const titleBgEnabled = !!titleSettings?.bgEnabled
const titleBgColor = titleSettings?.bgColor ?? "rgba(0,0,0,0.5)"
const titleBgPadding = ((titleSettings?.bgPadding ?? 12) / playRes.height) * containerHeight
const titleBgRadius = ((titleSettings?.bgRadius ?? 8) / playRes.height) * containerHeight
// ── Video 播放器(默认路径,浏览器原生硬件解码) ──
const {
@@ -561,14 +588,18 @@ const FrontendPreviewPlayer: React.FC<FrontendPreviewPlayerProps> = ({
color: titleSettings.color || "#ffffff",
fontWeight: titleSettings.bold ? 700 : 400,
fontStyle: titleSettings.italic ? "italic" : "normal",
lineHeight: 1.05,
lineHeight: titleSettings.lineHeight ?? 1.05,
wordBreak: "break-word",
WebkitTextStroke: titleSettings.stroke
? `${titleStrokeWidth}px #000000`
? `${titleStrokeWidth}px ${titleStrokeColor}`
: undefined,
textShadow: titleSettings.shadow
? `${titleShadowOffset}px ${titleShadowOffset}px ${titleShadowBlur}px rgba(0,0,0,0.8)`
textShadow: titleSettings.shadow ? titleShadowStr : undefined,
background: titleBgEnabled ? titleBgColor : undefined,
padding: titleBgEnabled
? `${titleBgPadding}px ${titleBgPadding * 1.5}px`
: undefined,
borderRadius: titleBgEnabled ? `${titleBgRadius}px` : undefined,
display: titleBgEnabled ? "inline-block" : undefined,
}}
>
{(effectiveTitle || "").split(/[//]/).map((part, i) => (