From c92a807c87e2c898608a6ac59565e908770ae17d Mon Sep 17 00:00:00 2001 From: xhgit <1+xhgit@noreply.git.xhmcl.com> Date: Sat, 14 Nov 2026 18:36:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(ai):=20=E9=87=8D=E5=8F=A0=E5=B9=B3=E7=A7=BB?= =?UTF-8?q?=E6=8C=A4=E5=BC=80=E6=97=A7=E7=89=87=E6=AE=B5=E6=97=B6=E8=A1=A5?= =?UTF-8?q?=E7=94=9F=E6=88=90=20update=20=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 实测:新建片段插入旧时间轴间隙、把旧片段挤开时,净化层只在 模拟里移动了旧片段,没有生成对应 update 操作——模拟通过校验、 实际应用时旧片段仍在原位,applyOperations 报「视频片段重叠」。 现在挤开旧片段时自动补一条 update 操作,模拟与实装一致。 新增回归测试(旧片段被挤开必须生成 update)。 --- desktop/core/project.mjs | 3 ++- tests/core.test.mjs | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/desktop/core/project.mjs b/desktop/core/project.mjs index 458016c..97f031e 100644 --- a/desktop/core/project.mjs +++ b/desktop/core/project.mjs @@ -140,7 +140,8 @@ export function sanitizeOperations(p,operations){ if(vids[i].start=5); const applied=applyOperations(p,r.operations); // 净化后的操作必须能直接通过校验 assert.equal(applied.clips.filter(c=>c.track==='video').length,3); + // 新增片段把旧片段挤开时,必须生成对应的 update 操作(否则模拟与实装不一致) + const p2=newProject('旧片段平移');p2.media=[{id:'v',type:'video',duration:60,name:'v',tags:[]}]; + p2.clips=[{id:'o1',mediaId:'v',track:'video',start:0,in:0,out:5,speed:1,volume:1},{id:'o2',mediaId:'v',track:'video',start:8,in:20,out:25,speed:1,volume:1}]; + const r2=sanitizeOperations(p2,[{type:'add',clip:{mediaId:'v',track:'video',start:0,in:5,out:15,speed:1}}]); + const shiftUpdate=r2.operations.find(o=>o.type==='update'&&o.id==='o2'); + assert.ok(shiftUpdate,'旧片段被挤开时必须生成 update 操作'); + assert.equal(shiftUpdate.changes.start,15); + const applied2=applyOperations(p2,r2.operations); + assert.equal(applied2.clips.find(c=>c.id==='o2').start,15); }); test('按参数组接:只使用已分析素材、按素材轮转保证多样性、忽略未分析素材',()=>{ const p=newProject('组接测试');p.media=[