diff --git a/public/icons/lock.svg b/public/icons/lock.svg new file mode 100644 index 0000000..6cf86f4 --- /dev/null +++ b/public/icons/lock.svg @@ -0,0 +1,2 @@ + +EOF < /dev/null diff --git a/src/services/editor.service.ts b/src/services/editor.service.ts index feec60d..03b64c3 100644 --- a/src/services/editor.service.ts +++ b/src/services/editor.service.ts @@ -632,6 +632,39 @@ export class EditorService extends Meta2d { this.updatePen(pointId, { statusStyle: color }, false); } + public updatePointLockIcon(pointId: string, show: boolean): void { + const pointPen = this.getPenById(pointId); + if (!pointPen || pointPen.name !== 'point') return; + + const lockIconId = `lock-icon-${pointId}`; + const existingIcon = this.getPenById(lockIconId); + + if (show) { + if (existingIcon) { + this.setValue({ id: lockIconId, visible: true }, { render: true, history: false, doEvent: false }); + } else { + const { x = 0, y = 0, width = 0 } = this.getPenRect(pointPen); + const iconPen: MapPen = { + id: lockIconId, + name: 'image', + tags: ['lock-icon'], + x: x - width / 2 - 20, // 在点左侧显示 + y: y - 10, + width: 16, + height: 16, + image: '/icons/lock.svg', + locked: LockState.Disable, + visible: true, + }; + this.addPen(iconPen, false, false, true); + } + } else { + if (existingIcon) { + this.setValue({ id: lockIconId, visible: false }, { render: true, history: false, doEvent: false }); + } + } + } + //#region 实时机器人 public async initRobots(): Promise { await Promise.all( diff --git a/src/services/storage-location.service.ts b/src/services/storage-location.service.ts index 37eaa85..c3e3e36 100644 --- a/src/services/storage-location.service.ts +++ b/src/services/storage-location.service.ts @@ -90,10 +90,15 @@ export class StorageLocationService { } const allOccupied = locations.every((loc) => loc.is_occupied); - const color = allOccupied ? '#ff4d4f' : '#52c41a'; // 全部占用红色,否则绿色 + const allLocked = locations.every((loc) => loc.is_locked); - // 通知编辑器更新点的边框颜色 + const color = allOccupied ? '#ff4d4f' : '#52c41a'; // 占用红色,否则绿色 + + // 更新边框颜色 this.editor?.updatePointBorderColor(pointId, color); + + // 更新锁定图标状态 + this.editor?.updatePointLockIcon(pointId, allLocked); } /**