diff --git a/src/apis/robot/type.ts b/src/apis/robot/type.ts index 8387185..e3664cc 100644 --- a/src/apis/robot/type.ts +++ b/src/apis/robot/type.ts @@ -1,4 +1,5 @@ import type { Point } from '@api/map'; +import type { Pen } from '@meta2d/core'; import type { RobotBrand, RobotState, RobotType } from './constant'; diff --git a/src/services/editor.service.ts b/src/services/editor.service.ts index 8f6b86e..6129b0d 100644 --- a/src/services/editor.service.ts +++ b/src/services/editor.service.ts @@ -1283,13 +1283,19 @@ export class EditorService extends Meta2d { const overlayId = `robot-status-${id}`; const exist = this.getPenById(overlayId); - if (!icon || !robotVisible) { + // 机器人不可见:隐藏覆盖图标 + if (!robotVisible) { if (exist) { this.setValue({ id: overlayId, visible: false }, { render, history: false, doEvent: false }); } return; } + // 没有状态图标时:如果之前有覆盖图标,则保持现状,不主动隐藏,避免无新数据推送时图标消失 + if (!icon) { + return; + } + // 如果已存在覆盖图标,更新其属性;否则创建新的 image 图元 if (exist) { this.setValue(