fix(cover): 修复AI数字人封面打开崩溃(.text undefined) #2037
Reference in New Issue
Block a user
Delete Branch "fix/shared-cover-crash-20260925"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
根因:后端 /cover-templates 返回的模板如果 config 字段缺失或只有部分字段(title/subtitle 对象为 undefined), CoverEditorModal 用浅拷贝 {...template?.config} 初始化 state,导致 cfg.title/cfg.subtitle 为 undefined, 后续渲染时访问 tc.text 触发崩溃。useSharedCover 在拉取模板后未做 config 字段归一化,首次打开时传入 缺少字段的模板对象给 CoverEditorModal 也会触发。 修复: - CoverEditorModal 新增 mergeEditorConfig 深合并工具:缺失字段用 DEFAULT_EDITOR_CONFIG 补齐, 对 title/subtitle/shadows/background/position 等嵌套对象做深拷贝,避免共享引用 - 初始化 cfg 与 open 时重置 state 都改用 mergeEditorConfig - renderTextStyle/renderTextLines/TextStylePanel 增加 null/undefined 防御 - 画布渲染处 cfg.title && cfg.subtitle && 条件渲染 - useSharedCover 的 reloadTemplates 兼容 {items:[]} 与直接数组两种响应格式,并确保每个模板都带 config 字段 tsc/eslint/prettier 全过,构建产物 bundle 检查无不安全的 .text 访问。🚀 预览环境已部署
CI全绿,自动审批通过。
CI全绿,自动审批通过。
🗑️ 预览环境已清理
PR #2037 已关闭或合并,对应的预览环境已被清理。