Explorar o código

箭头入口和白线重合

yichael hai 5 meses
pai
achega
bc3a657e03
Modificáronse 2 ficheiros con 31 adicións e 15 borrados
  1. 20 4
      src/pages/blueprint/canvas/canvas.js
  2. 11 11
      static/processing/测试/bp.json

+ 20 - 4
src/pages/blueprint/canvas/canvas.js

@@ -377,12 +377,28 @@ export function useCanvasLogic(connections, externalControllerRef, nodes = []) {
           // 端口垂直居中 = node.y + headerHeight + executionHeight / 2
           portCenterY = node.y + headerHeight + executionHeight / 2;
           
+          // 箭头是 CSS border 三角形:border-width: 6px 0 6px 10px
+          // 箭头宽度10px,高度12px,箭头中心在宽度的中点(5px)
+          const arrowWidth = 10;
+          const arrowHalfWidth = arrowWidth / 2; // 5px
+          
           if (isInput) {
-            // 执行输入端口:在节点左侧
-            portCenterX = node.x + 8; // padding: 0 8px
+            // 执行输入端口箭头:
+            // 执行区域 padding: 0 8px,端口从 node.x + 8 开始
+            // 箭头有 margin-left: 5%(约9px,按180px宽度算)
+            // 箭头中心 ≈ node.x + 8 + 9 + 5 = node.x + 22
+            // 简化:箭头中心约在 node.x + 8 + arrowHalfWidth + 一些margin
+            portCenterX = node.x + 8 + arrowHalfWidth + 8; // 加上margin估算
           } else {
-            // 执行输出端口:在节点右侧
-            portCenterX = node.x + nodeDims.width - 8;
+            // 执行输出端口箭头:
+            // 执行区域 padding: 0 8px,端口容器在右侧(margin-left: auto)
+            // 箭头有 margin-right: -8px,箭头向右伸出到节点边缘外
+            // 端口容器右边缘在 node.x + width - 8(padding)
+            // 箭头因为 margin-right: -8px 向右伸出8px
+            // 箭头宽度10px,箭头尖端在 node.x + width - 8 + 8 + 10 = node.x + width + 10
+            // 箭头中心(几何中心)在箭头尖端左边 5px 处
+            // 箭头中心 = node.x + width + 10 - 5 = node.x + width + 5
+            portCenterX = node.x + nodeDims.width + arrowHalfWidth;
           }
         } else {
           // 数据端口:在参数区域内

+ 11 - 11
static/processing/测试/bp.json

@@ -1,20 +1,20 @@
 {
 	"nodePositions": {
-		"node_begin_1768719615224": {
-			"x": 80,
-			"y": 160
+		"node_begin_1768720215708": {
+			"x": 100,
+			"y": 100
 		},
 		"node_0": {
-			"x": 360,
-			"y": 180
+			"x": 420,
+			"y": 120
 		},
-		"var_get_mini_1768719615225": {
-			"x": 80,
-			"y": 420
+		"var_get_mini_1768720215708": {
+			"x": 100,
+			"y": 380
 		},
-		"var_set_swipeDirection_1768719615225": {
-			"x": 700,
-			"y": 420
+		"var_set_swipeDirection_1768720215708": {
+			"x": 540,
+			"y": 460
 		}
 	}
 }