Compare commits

...

3 Commits

4 changed files with 44 additions and 3 deletions

2
public/icons/lock.svg Normal file
View File

@ -0,0 +1,2 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12 17a2 2 0 0 0 2-2 2 2 0 0 0-2-2 2 2 0 0 0-2 2 2 2 0 0 0 2 2m6-9a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2h1V6a5 5 0 0 1 10 0v2h1m-6-4a3 3 0 0 0-3 3v2h6V6a3 3 0 0 0-3-3Z"/></svg>
EOF < /dev/null

After

Width:  |  Height:  |  Size: 308 B

View File

@ -138,7 +138,7 @@ onMounted(async () => {
await readScene(); await readScene();
await editor.value?.initRobots(); await editor.value?.initRobots();
await monitorScene(); await monitorScene();
await storageLocationService.value?.startMonitoring({ interval: 3 }); storageLocationService.value?.startMonitoring({ interval: 3 });
// //
await handleAutoSaveAndRestoreViewState(); await handleAutoSaveAndRestoreViewState();
}); });

View File

@ -632,6 +632,40 @@ export class EditorService extends Meta2d {
this.updatePen(pointId, { statusStyle: color }, false); 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 } = this.getPenRect(pointPen);
const iconPen: MapPen = {
id: lockIconId,
name: 'circle',
tags: ['lock-icon'],
x: x + 48, // 在点右侧显示
y: y + 60,
width: 8,
height: 8,
background: '#ff4d4f', // 红色背景
color: '#ff4d4f',
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 实时机器人 //#region 实时机器人
public async initRobots(): Promise<void> { public async initRobots(): Promise<void> {
await Promise.all( await Promise.all(

View File

@ -90,10 +90,15 @@ export class StorageLocationService {
} }
const allOccupied = locations.every((loc) => loc.is_occupied); 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?.updatePointBorderColor(pointId, color);
// 更新锁定图标状态
this.editor?.updatePointLockIcon(pointId, allLocked);
} }
/** /**