feat: 在机器人类型中添加 Pen 类型导入,优化编辑服务中的覆盖图标逻辑以提升用户体验

This commit is contained in:
xudan 2025-09-15 17:44:56 +08:00
parent c5064b189c
commit 5d56362848
2 changed files with 8 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import type { Point } from '@api/map';
import type { Pen } from '@meta2d/core';
import type { RobotBrand, RobotState, RobotType } from './constant';

View File

@ -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(