From 3b78d7519ef2c98079dfbbf7e0e8b3546c85c20b Mon Sep 17 00:00:00 2001 From: caill <815519168@qq.com> Date: Wed, 20 Aug 2025 19:05:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B2=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/modules/map.vue | 22 +- src/pages/modules/map的副本.vue | 542 +++++++++++++++++++++++++++++ 2 files changed, 562 insertions(+), 2 deletions(-) create mode 100644 src/pages/modules/map的副本.vue diff --git a/src/pages/modules/map.vue b/src/pages/modules/map.vue index d32b499..5225927 100644 --- a/src/pages/modules/map.vue +++ b/src/pages/modules/map.vue @@ -292,14 +292,32 @@ export default { }, 30), drawPath () { if (!this.pathData.length) return - this.pathData.forEach(point => { + this.pathData.forEach((point, index) => { const startX = (point.start_x - this.mapData.x) / this.mapData.resolution const startY = this.mapData.height - (point.start_y - this.mapData.y) / this.mapData.resolution const endX = (point.end_x - this.mapData.x) / this.mapData.resolution const endY = this.mapData.height - (point.end_y - this.mapData.y) / this.mapData.resolution + + const nextPoint = this.pathData[index + 1]; + let controlX, controlY; + + if (nextPoint) { + // 有下一个点时,使用当前终点和下一个起点的中点作为控制点 + const nextStartX = (nextPoint.start_x - this.mapData.x) / this.mapData.resolution; + const nextStartY = this.mapData.height - (nextPoint.start_y - this.mapData.y) / this.mapData.resolution; + controlX = (endX + nextStartX) / 2; + controlY = (endY + nextStartY) / 2; + } else { + // 最后一个点,使用当前终点作为控制点 + controlX = endX; + controlY = endY; + } + this.ctx.beginPath() this.ctx.moveTo(startX, startY) - this.ctx.lineTo(endX, endY) + + this.ctx.quadraticCurveTo(controlX, controlY, endX, endY); + if (this.selectedPath.route_id === point.route_id) { this.ctx.strokeStyle = '#ff5722' // 橙色高亮 this.ctx.lineWidth = 4 diff --git a/src/pages/modules/map的副本.vue b/src/pages/modules/map的副本.vue new file mode 100644 index 0000000..d32b499 --- /dev/null +++ b/src/pages/modules/map的副本.vue @@ -0,0 +1,542 @@ + + + + + +