From db5b2275f76a7ff4265e30c6903759b32f6a1fba Mon Sep 17 00:00:00 2001 From: xudan Date: Fri, 28 Nov 2025 11:10:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(editor-robot):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=9C=BA=E5=99=A8=E4=BA=BA=E7=8A=B6=E6=80=81=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E5=B1=82=E5=8F=AF=E8=A7=81=E6=80=A7=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E4=BB=85=E5=9C=A8=E6=9C=89=E6=95=88=E4=BD=8D=E7=BD=AE=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=97=B6=E6=98=BE=E7=A4=BA=E9=81=BF=E5=85=8D=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E4=BD=8D=E7=BD=AE=E9=97=AA=E7=83=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/editor/editor-robot.service.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/services/editor/editor-robot.service.ts b/src/services/editor/editor-robot.service.ts index 820671f..92dffb0 100644 --- a/src/services/editor/editor-robot.service.ts +++ b/src/services/editor/editor-robot.service.ts @@ -321,16 +321,20 @@ export class EditorRobotService { const pen = this.ctx.getPenById(id); if (!pen) return; - // [关键修复] 强制同步可见性,防止因底层库时序问题导致的状态不一致。 - // 在回放模式下,上游的 setValue 可能不会立即生效,导致此处的 pen.visible 仍为 false。 - if (pen.visible === false) { + // [修复] 只有在机器人有有效位置数据时才设置为可见,避免在初始位置闪烁 + const hasValidPosition = (pen.x !== undefined && pen.y !== undefined && + (pen.x !== 0 || pen.y !== 0)) || + (newPosition?.x !== undefined && newPosition?.y !== undefined && + (newPosition.x !== 0 || newPosition.y !== 0)); + + // 只有在机器人有有效位置且当前不可见时,才设置为可见 + if (hasValidPosition && pen.visible === false) { this.ctx.setValue({ id, visible: true }, { render: false, history: false, doEvent: false }); } const icon = this.getRobotStatusIcon(pen); - // 鉴于上面已经强制设置了 visible,此处直接使用 true 或重新检查 pen.visible 均可。 - // 为确保逻辑的健壮性,我们直接使用 true。 - const robotVisible = true; + // 机器人可见性取决于是否有有效位置数据 + const robotVisible = hasValidPosition; const baseW = (pen as any).iconWidth ?? 42; const baseH = (pen as any).iconHeight ?? 76;