feat(title): 标题自由位置拖拽后端支持——pos_x/pos_y 注入 \pos 定位 #1592

Merged
xiaoxia merged 1 commits from feat/title-drag-position into develop 2026-09-01 12:31:12 +08:00
Owner

工单 #1405 方案 B:标题自由位置拖拽(后端)

前端支持用户在预览画面自由拖拽标题位置,后端烧录 ASS 时按坐标定位。只改 Title(标题),Subtitle(配音字幕)逻辑不动。

改动

packages/domain/ass_subtitle_builder.py

  • title_config 新增可选字段 pos_xpos_y(PlayRes 坐标系像素整数,PlayResX/Y = video_width/video_height)
  • 两字段同时存在、为 int(bool/float/字符串/None 拒绝)、且落在 [0, video_width]×[0, video_height] 闭区间内时:
    • TitleStyle Alignment 固定 5\an5 中对齐,使 \pos 锚点为文本块中心)
    • Title Dialogue 文本前注入 {\pos(x,y)} override tag(如 {\pos(540,300)}标题文本
  • 字段缺失/非法/越界 → 一律回退现有 position → alignment 三档逻辑,top/center/bottom 输出一字节不变
  • 未动:subtitle 段、position_to_ass_alignment、Style 行格式

测试

新增 9 个单测:

  1. 合法坐标 → Dialogue 含 {\pos(x,y)} 且 TitleStyle Alignment=5
  2. 边界值 (0, height)/(width, 0) 合法
  3. 不传坐标 → 输出与现有断言完全一致(回归保护)
  4. 越界坐标(负值/超宽高)→ 回退且输出逐字节一致
  5. 非法类型(字符串/None/bool/float)→ 回退
  6. 只传 pos_x 或 pos_y → 回退
  7. 三档 top=8/center=5/bottom=2 对齐不变
  8. 有 pos 时覆盖 position,Alignment 恒为 5
  9. Subtitle 段不受 pos 影响

3140 相关测试全过。

## 工单 #1405 方案 B:标题自由位置拖拽(后端) 前端支持用户在预览画面自由拖拽标题位置,后端烧录 ASS 时按坐标定位。**只改 Title(标题),Subtitle(配音字幕)逻辑不动。** ## 改动 `packages/domain/ass_subtitle_builder.py`: - `title_config` 新增可选字段 `pos_x`、`pos_y`(PlayRes 坐标系像素整数,PlayResX/Y = video_width/video_height) - 两字段同时存在、为 int(bool/float/字符串/None 拒绝)、且落在 `[0, video_width]×[0, video_height]` 闭区间内时: - TitleStyle Alignment 固定 **5**(`\an5` 中对齐,使 `\pos` 锚点为文本块中心) - Title Dialogue 文本前注入 `{\pos(x,y)}` override tag(如 `{\pos(540,300)}标题文本`) - 字段缺失/非法/越界 → 一律回退现有 position → alignment 三档逻辑,top/center/bottom 输出**一字节不变** - 未动:subtitle 段、`position_to_ass_alignment`、Style 行格式 ## 测试 新增 9 个单测: 1. 合法坐标 → Dialogue 含 `{\pos(x,y)}` 且 TitleStyle Alignment=5 2. 边界值 (0, height)/(width, 0) 合法 3. 不传坐标 → 输出与现有断言完全一致(回归保护) 4. 越界坐标(负值/超宽高)→ 回退且输出逐字节一致 5. 非法类型(字符串/None/bool/float)→ 回退 6. 只传 pos_x 或 pos_y → 回退 7. 三档 top=8/center=5/bottom=2 对齐不变 8. 有 pos 时覆盖 position,Alignment 恒为 5 9. Subtitle 段不受 pos 影响 3140 相关测试全过。
xiaoxia added 1 commit 2026-09-01 01:26:03 +08:00
feat(title): 标题自由位置拖拽后端支持——pos_x/pos_y 注入 \\pos 定位
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1s
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web 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
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 4m3s
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 API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 4m35s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m41s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 2m31s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 7m0s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 4m22s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 5m16s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 5m17s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 6m9s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 5m50s
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Successful in 0s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
AI Code Review / AI Code Review (pull_request) Successful in 9m52s
34e8c56584
工单 #1405 方案 B:前端支持用户在预览画面自由拖拽标题位置,
后端烧录 ASS 时按坐标定位。只动 Title,Subtitle 逻辑不变。

- title_config 新增可选字段 pos_x、pos_y(PlayRes 像素整数,
  PlayResX/Y = video_width/video_height)
- 两字段同时存在、为 int(bool/float/字符串拒绝)、且落在
  [0,video_width]×[0,video_height] 闭区间内时:
  - TitleStyle Alignment 固定 5(\an5 中对齐,\pos 锚点为文本块中心)
  - Dialogue 文本前注入 {\pos(x,y)} override tag
- 字段缺失/非法/越界一律回退 position → alignment 三档逻辑,
  现有 top/center/bottom 输出一字节不变
- 新增 9 个单测:合法坐标注入、边界值、无坐标回归、越界回退、
  非法类型回退(含 bool/float/None/字符串)、单字段回退、
  三档对齐不变、pos 覆盖 position、subtitle 不受影响

🚀 预览环境已部署

项目 详情
PR号 #1592
预览链接 https://pr-1592.preview.xiaoxiajianji.com
API环境 staging

💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。

🔄 每次提交新代码后预览环境会自动更新。

🗑️ PR 关闭或合并后,预览环境会自动清理。

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #1592 | | 预览链接 | [https://pr-1592.preview.xiaoxiajianji.com](https://pr-1592.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
xiaoxia added 1 commit 2026-09-01 12:31:01 +08:00
Merge branch 'develop' into feat/title-drag-position
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 3s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 3s
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 / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web 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
ACR Cleanup / ACR Image Cleanup (pull_request_target) Has been cancelled
AI Code Review / AI Code Review (pull_request) Successful in 4m36s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 4m21s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 5m1s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 5m11s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Validate - Style (pull_request) Successful in 5m34s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 6m4s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 6m13s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 6m9s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 6m52s
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
PR Automation / Auto Approve on CI Green (pull_request) Successful in 7m52s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 8m17s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 22m54s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Successful in 4s
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
32f1107595
xiaoxia merged commit 1a2c4b89be into develop 2026-09-01 12:31:12 +08:00

🗑️ 预览环境已清理

PR #1592 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #1592 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Sign in to join this conversation.