From 0a664afd14d07cecf318d37492630a8cfdebea3a Mon Sep 17 00:00:00 2001 From: xudan Date: Tue, 9 Sep 2025 10:31:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=8F=8C=E5=90=91?= =?UTF-8?q?=E8=B7=AF=E7=BA=BF=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=8E=B7=E5=8F=96=E3=80=81=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E5=92=8C=E5=88=A0=E9=99=A4=E5=8F=8C=E5=90=91=E8=B7=AF=E7=BA=BF?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E8=B7=AF=E7=BA=BF=E6=96=B9=E5=90=91?= =?UTF-8?q?=E5=92=8C=E7=B1=BB=E5=9E=8B=E7=9A=84=E5=A4=84=E7=90=86=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/card/route-edit-card.vue | 75 ++++++++++++++- src/services/editor.service.ts | 119 ++++++++++++++++++++++++ 2 files changed, 190 insertions(+), 4 deletions(-) diff --git a/src/components/card/route-edit-card.vue b/src/components/card/route-edit-card.vue index ba32cab..2116eae 100644 --- a/src/components/card/route-edit-card.vue +++ b/src/components/card/route-edit-card.vue @@ -28,6 +28,56 @@ const route = computed(() => { if (!v?.type) return null; return v; }); + +// 双向路线管理 +const connectedRoutes = computed(() => { + if (!pen.value) return []; + const [a1, a2] = pen.value.anchors ?? []; + if (!a1?.connectTo || !a2?.connectTo) return []; + return editor.value.getRoutesBetweenPoints(a1.connectTo, a2.connectTo); +}); + +const currentRoute = computed(() => { + return pen.value; +}); + +const oppositeRoute = computed(() => { + if (!currentRoute.value) return null; + const [a1, a2] = currentRoute.value.anchors ?? []; + if (!a1?.connectTo || !a2?.connectTo) return null; + + return connectedRoutes.value.find(r => r.id !== currentRoute.value?.id) || null; +}); + +const isBidirectional = computed(() => { + return connectedRoutes.value.length >= 2; +}); + + +// 处理路线方向变化 +function handleDirectionChange(direction: any) { + if (!props.id) return; + editor.value.updateRoute(props.id, { direction: Number(direction) as -1 | 1 }); +} + +// 处理路线类型变化 +function handleRouteTypeChange(type: any) { + if (!props.id) return; + editor.value.changeRouteType(props.id, Number(type) as unknown as MapRouteType); +} + +// 处理反向路线方向变化 +function handleOppositeDirectionChange(direction: any) { + if (!oppositeRoute.value?.id) return; + editor.value.updateRoute(oppositeRoute.value.id, { direction: Number(direction) as -1 | 1 }); +} + +// 处理通行类型变化 +function handlePassChange(pass: any) { + if (!props.id) return; + editor.value.updateRoute(props.id, { pass: Number(pass) as MapRoutePassType }); +} +