From f3b993d31d4ccf1b5121ef3904ae0b3cd9059cc2 Mon Sep 17 00:00:00 2001 From: xudan Date: Fri, 15 Aug 2025 15:11:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E6=9C=8D=E5=8A=A1=E4=BB=A5=E7=A1=AE=E4=BF=9D=E7=82=B9?= =?UTF-8?q?=E4=BD=8D=E5=9C=A8=E8=B7=AF=E7=BA=BF=E4=B8=8A=E6=96=B9=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E8=B0=83=E6=95=B4=E9=94=9A=E7=82=B9=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E4=BB=A5=E4=BC=98=E5=8C=96=E5=9B=BE=E5=BD=A2=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/map/constant.ts | 4 ++-- src/services/editor.service.ts | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/apis/map/constant.ts b/src/apis/map/constant.ts index 4819e30..afcdf87 100644 --- a/src/apis/map/constant.ts +++ b/src/apis/map/constant.ts @@ -147,8 +147,8 @@ export const EDITOR_CONFIG: Options = { disableRotate: true, /** 禁用尺寸调整 - 允许图形大小调整 */ disableSize: false, - /** 禁用锚点 - 禁用连接锚点显示 */ - disableAnchor: false, + /** 禁用锚点 - 禁用连接锚点显示,点位不需要锚点,只有区域需要 */ + disableAnchor: true, /** 禁用空线条 - 不允许创建没有连接点的线条 */ disableEmptyLine: true, /** 禁用重复线条 - 不允许在同一对点之间创建多条线 */ diff --git a/src/services/editor.service.ts b/src/services/editor.service.ts index f4da0b3..4174c98 100644 --- a/src/services/editor.service.ts +++ b/src/services/editor.service.ts @@ -70,6 +70,10 @@ export class EditorService extends Meta2d { await this.#loadScenePoints(points, isImport); this.#loadSceneRoutes(routes, isImport); await this.#loadSceneAreas(areas, isImport); + + // 确保加载的点位在路线上方 + this.#ensurePointsOnTop(); + this.store.historyIndex = undefined; this.store.histories = []; // this.scale(scale);与xd 自定义缩放冲突,暂时去掉 @@ -496,6 +500,17 @@ export class EditorService extends Meta2d { } return area; } + + /** + * 确保所有点位在路线上方 + * 将所有点位移到绘制顺序的最上层 + */ + #ensurePointsOnTop(): void { + const points = this.find('point'); + if (points.length > 0) { + this.top(points); + } + } //#endregion /** @@ -967,7 +982,10 @@ export class EditorService extends Meta2d { }; pen.x! -= pen.width! / 2; pen.y! -= pen.height! / 2; - await this.addPen(pen, false, true, true); + const addedPen = await this.addPen(pen, false, true, true); + + // 将点位移到最上层,确保它们始终显示在路线之上 + this.top([addedPen]); } public updatePoint(id: string, info: Partial): void { @@ -1052,9 +1070,19 @@ export class EditorService extends Meta2d { const line = this.connectLine(p1, p2, undefined, undefined, false); id ||= line.id!; this.changePenId(line.id!, id); - const pen: MapPen = { tags: ['route'], route: { type }, lineWidth: 1, locked: LockState.DisableEdit }; + const pen: MapPen = { + tags: ['route'], + route: { type }, + lineWidth: 1, + locked: LockState.DisableEdit, + canvasLayer: CanvasLayer.CanvasMain, + }; this.setValue({ id, ...pen }, { render: false, history: false, doEvent: false }); this.updateLineType(line, type); + + // 将路线移到底层,确保点位能覆盖在路线之上 + this.bottom([line]); + this.active(id); this.render(); }