From 80d707f992e1347efb380c0a422c641295c8909b Mon Sep 17 00:00:00 2001 From: limengnan <420004014@qq.com> Date: Thu, 15 Jan 2026 17:27:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9x6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../x6/expansionandcontraction-left.png | Bin 0 -> 304 bytes .../x6/expansionandcontraction-right.png | Bin 0 -> 312 bytes .../frontend/src/components/antvx6/index.vue | 147 +++++++++++++++++- .../src/views/business/project/index.vue | 2 +- 4 files changed, 140 insertions(+), 9 deletions(-) create mode 100644 business-css/frontend/src/assets/x6/expansionandcontraction-left.png create mode 100644 business-css/frontend/src/assets/x6/expansionandcontraction-right.png diff --git a/business-css/frontend/src/assets/x6/expansionandcontraction-left.png b/business-css/frontend/src/assets/x6/expansionandcontraction-left.png new file mode 100644 index 0000000000000000000000000000000000000000..1bad4762cd6b7b33d368a5ebcf69247d9036c961 GIT binary patch literal 304 zcmeAS@N?(olHy`uVBq!ia0vp^Y(UJz0U{m4&*%Xu#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!;89N(#}JL+#n;-}l%5uUoZl-8n{`!1(y{2ag{8`se%m``;VgBpZ*+ zaArZ_s2(Pu@sd%@($g-jc)%~t)57A x^gk+|5Z@qFzQ6W&8JjB;i^IO>k00OWW?;JF+c58<6(i6?44$rjF6*2UngC}Ld?)|_ literal 0 HcmV?d00001 diff --git a/business-css/frontend/src/assets/x6/expansionandcontraction-right.png b/business-css/frontend/src/assets/x6/expansionandcontraction-right.png new file mode 100644 index 0000000000000000000000000000000000000000..f0537599cbb4ebb7b5cfed3d916e166835632255 GIT binary patch literal 312 zcmeAS@N?(olHy`uVBq!ia0vp^Y(UJz0U{m4&*%Xu#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!;8{->#}JL+k|Nrx6PM!Kyr-Pp< zfpfyD`v3o4GN`6RMMa%!JaWM8phIct);$v@Tv)3gzwZsx>jp+Kv1$Dd%Js%ZMqCF< zuUx-gykYa^`)nH<%T^sKWjJep?97=n%t9ygcuYVreNUv7+MQ z=zZ1S&oO2E^q!!=VZaz#wYUDioq&YN^aV){2M#bWNKf$FvsNJn { }, }, }, + interacting: function (cellView) { + // 获取当前节点的模型 + const cell = cellView.cell + // 判断节点是否为 'rect' 形状 + if (cell.shape === 'rect') { + // 如果是 'rect' 形状,则禁止节点移动 + return { nodeMovable: false } + } + // 其他形状的节点允许所有交互 + return true + } + // interacting: { + // nodeMovable: false, // 禁止所有节点移动 + // }, }) // #endregion @@ -151,7 +166,7 @@ onMounted(() => { .use( new Transform({ resizing: false, // 通过拖拽边缘调整节点大小 - rotating: true, // 允许旋转节点 + rotating: false, // 允许旋转节点 // scaling 不是 Transform 插件的有效配置项,已移除 }), ) @@ -237,7 +252,7 @@ onMounted(() => { ?.appendChild(stencil.container as HTMLElement) // 监听Graph中节点创建事件 - graph.on('node:added', (args) => { + graph.on('node:added', (args:any) => { console.log('节点已添加到画布', args) const { node } = args @@ -264,6 +279,9 @@ onMounted(() => { graph.removeNode(node) }, 100) } else { + if(node.store && node.store.data && node.store.data.shape === 'rect'){ + return + } // 设置固定大小 node.size(160, 160) // 去掉背景节点 @@ -349,6 +367,59 @@ onMounted(() => { } }) + + + + let startPoint:any = null // 矩形起点 + +// 监听鼠标按下事件:记录起点 +graph.on('blank:mousedown', (e) => { + startPoint = { x: e.x, y: e.y } +}) + +// 监听鼠标松开事件:绘制矩形 +graph.on('blank:mouseup', (e) => { + console.log('鼠标松开事件', e) + if (!startPoint) return + + + const endPoint = { x: e.x, y: e.y } + if(Math.abs(endPoint.x - startPoint.x) <20 && Math.abs(endPoint.y - startPoint.y) <20){ + return + } + const width = Math.abs(endPoint.x - startPoint.x) + const height = Math.abs(endPoint.y - startPoint.y) + const x = Math.min(startPoint.x, endPoint.x) + const y = Math.min(startPoint.y, endPoint.y) + + // 添加矩形节点(设置 zIndex 为 -1 确保在最底层) + graph.addNode({ + shape: 'rect', + x, + y, + width, + height, + zIndex: -1, // 关键:置于底层 + // interactive: false, // 禁用所有交互 + // selectable: false, // 明确禁止选中 + draggable: false, // 明确禁止移动 + interacting: { + nodeMovable: false, // 禁止所有节点移动 + }, + attrs: { + body: { + fill: 'transparent', + stroke: '#999', + strokeWidth: 1, + strokeDasharray: '5 5', // 设置虚线样式 + }, + }, + }) + + startPoint = null // 重置起点 +}) + + // 控制连接桩显示/隐藏 const showPorts = (ports: NodeListOf, show: boolean) => { for (let i = 0, len = ports.length; i < len; i += 1) { @@ -846,15 +917,15 @@ function handleClose() { -->
-
- 图标 +
+ 图标
{{ projectInfo.name }}
-
- 图标 +
+ 图标
-
- 图标 +
+ 图标
@@ -895,6 +966,20 @@ function handleClose() { 图标
+
+
+ +
+
+
+ +
+
+
样式
+
+
+ +
\ No newline at end of file diff --git a/business-css/frontend/src/views/business/project/index.vue b/business-css/frontend/src/views/business/project/index.vue index 248823f..95ab3a9 100644 --- a/business-css/frontend/src/views/business/project/index.vue +++ b/business-css/frontend/src/views/business/project/index.vue @@ -277,7 +277,7 @@ function closeAntvx6() { -
+