From 4cfadcea0836ab9cb3095019662250517c018b1a Mon Sep 17 00:00:00 2001 From: WuYongJie <549727955@qq.com> Date: Mon, 16 Nov 2026 18:39:11 +0800 Subject: [PATCH] Keep intentionally cleared canvas text empty on reload --- docs/模型参数核对-2026-11-16.md | 2 +- lib/video-canvas/text-resource.ts | 6 ++---- tests/routes/video-canvas-tasks.test.ts | 6 +++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/模型参数核对-2026-11-16.md b/docs/模型参数核对-2026-11-16.md index 46138ef37..8edbfdfce 100644 --- a/docs/模型参数核对-2026-11-16.md +++ b/docs/模型参数核对-2026-11-16.md @@ -139,7 +139,7 @@ 本轮修复语音识别成功后画布结果为空的问题:新结果采用画布文本结构,已保存的字符串结果也可直接显示和编辑;重复查询不会覆盖人工修改。音频生成节点显示排队、处理中及失败信息,不再以空播放器及默认三秒时长表示未完成任务。相关回归 72 项和 TypeScript 检查通过;内置浏览器独立页面已验证新旧文字显示、中文与尺寸编辑、空格保留及等待/失败状态,待正式发布。 -画布恢复时统一读取字符串和数组格式的文本,保留中文、尺寸及空格;缺少内容的历史识别节点从已保存的识别文本恢复,人工编辑和主动清空保持优先。恢复与任务相关回归 46 项、TypeScript 检查及内置浏览器的实际恢复组件验收通过,等待生产画布刷新验收。 +画布恢复时统一读取字符串和数组格式的文本,保留中文、尺寸及空格;人工编辑和主动清空按画布保存内容显示。恢复与任务相关回归 46 项、TypeScript 检查及内置浏览器的实际恢复组件验收通过,等待生产画布刷新验收。 音乐原任务已成功完成并保存七牛,网页解码时长约 150 秒并可播放。供应商核对确认只受理及扣费一次;本项目工作进程续查一次原任务,没有重新派发。声音克隆与声音设计在内置浏览器均播放到结尾。 diff --git a/lib/video-canvas/text-resource.ts b/lib/video-canvas/text-resource.ts index e932a5951..565a9986e 100644 --- a/lib/video-canvas/text-resource.ts +++ b/lib/video-canvas/text-resource.ts @@ -1,9 +1,7 @@ export function restoreTextResourceContent(draft?: Record): string[] { const content = draft?.content; if (typeof content === "string") return [content]; - // An empty string in the array is an intentional edit and must stay empty. - if (Array.isArray(content) && content.length) return content; - if (draft?.audioMeta?.outputType === "text" && typeof draft.text === "string") - return [draft.text]; + // Empty arrays and strings both represent an intentional edit. + if (Array.isArray(content)) return content; return []; } diff --git a/tests/routes/video-canvas-tasks.test.ts b/tests/routes/video-canvas-tasks.test.ts index 5bb429f9d..fe83992a8 100644 --- a/tests/routes/video-canvas-tasks.test.ts +++ b/tests/routes/video-canvas-tasks.test.ts @@ -94,10 +94,10 @@ test("saved speech text survives reload and retains subsequent edits, including const text = "这是由壹点测试画布的语音验收,尺寸 15mm。 "; const saved = { content: text, text, audioMeta: { outputType: "text" } }; expect(restoreTextResourceContent(JSON.parse(JSON.stringify(saved)))).toEqual([text]); - expect(restoreTextResourceContent({ ...saved, content: [] })).toEqual([text]); + expect(restoreTextResourceContent({ ...saved, content: [] })).toEqual([]); for (const edit of ["已校对的中文 20mm。 ", ""]) { - const updated = { ...saved, content: [edit] }; - expect(restoreTextResourceContent(JSON.parse(JSON.stringify(updated)))).toEqual([edit]); + const updated = { ...saved, content: edit ? [edit] : [] }; + expect(restoreTextResourceContent(JSON.parse(JSON.stringify(updated)))).toEqual(edit ? [edit] : []); } expect(restoreTextResourceContent({ content: [] })).toEqual([]); });