@mx-sose-front/mx-sose-graph 1.1.8 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/edgeWorker-b57ca007.js +2 -0
- package/dist/assets/edgeWorker-b57ca007.js.map +1 -0
- package/dist/index.d.ts +633 -30
- package/dist/index.esm.js +8728 -4734
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/Common/Tree.vue +451 -0
- package/src/components/Common/index.ts +2 -0
- package/src/components/DiagramListTooltip/DiagramListTooltip.vue +1 -2
- package/src/components/Edge/Edge.vue +172 -169
- package/src/components/Gantt/Gantt.vue +1544 -0
- package/src/components/GanttContextMenu/GanttContextMenu.vue +304 -0
- package/src/components/InteractionLayer.vue +343 -147
- package/src/components/Matrix/Matrix.vue +828 -0
- package/src/components/Matrix/index.ts +168 -0
- package/src/components/Shape/ConceptualRole.vue +2 -34
- package/src/components/Table/Table.vue +970 -0
- package/src/constants/edgeShapeKeys.ts +8 -5
- package/src/constants/index.ts +259 -45
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useChartRowSelection.ts +456 -0
- package/src/hooks/useResize.ts +2 -2
- package/src/hooks/useVirtualScroll.ts +258 -0
- package/src/index.ts +1 -1
- package/src/render/shape-renderer.ts +62 -2
- package/src/statics/icons/childIcons//345/221/275/344/273/244@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/346/246/202/345/277/265/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//346/216/247/345/210/266@3x.png +0 -0
- package/src/statics/icons/createMenu/down.png +0 -0
- package/src/statics/icons/createMenu/remove.png +0 -0
- package/src/statics/icons/createMenu/up.png +0 -0
- package/src/store/graphStore.ts +217 -44
- package/src/types/index.ts +86 -4
- package/src/utils/batchAutoExpand.ts +9 -10
- package/src/utils/containers.ts +72 -17
- package/src/utils/contextMenuUtils.ts +7 -7
- package/src/utils/dateUtils.ts +160 -0
- package/src/utils/diagram.ts +10 -8
- package/src/utils/drag.ts +6 -5
- package/src/utils/edgeUtils.ts +344 -427
- package/src/utils/edgeWorker.ts +471 -0
- package/src/utils/hittest.ts +37 -38
- package/src/utils/index.ts +3 -0
- package/src/utils/keyboardUtils.ts +5 -5
- package/src/utils/packageOutline.ts +96 -0
- package/src/utils/rafThrottle.ts +162 -0
- package/src/utils/workerManager.ts +335 -0
- package/src/view/graph.vue +47 -33
- /package/src/statics/icons/childIcons//346/210/230/347/225/{245@3x.png" → 245/345/261/202@3x.png"} +0 -0
|
@@ -5,40 +5,77 @@
|
|
|
5
5
|
zIndex: props.shape.style?.zIndex
|
|
6
6
|
}" @click.stop="handleClick($event)">
|
|
7
7
|
<svg class="edge-svg" :viewBox="svgViewBox" :width="containerWidth" :height="containerHeight">
|
|
8
|
-
<!-- 引入线条样式标记组件 -->
|
|
9
8
|
<LineStyleMarker :shape-key="shapeKey" />
|
|
10
9
|
|
|
11
|
-
<polyline
|
|
12
|
-
|
|
10
|
+
<polyline
|
|
11
|
+
:points="linePoints"
|
|
12
|
+
:stroke="edgeColor"
|
|
13
|
+
:stroke-width="strokeWidth"
|
|
14
|
+
:stroke-dasharray="strokeDashArray"
|
|
15
|
+
fill="none"
|
|
16
|
+
@click.stop="handleClick($event)"
|
|
17
|
+
:marker-start="getMarkerStart()"
|
|
18
|
+
:marker-end="getMarkerEnd()"
|
|
19
|
+
/>
|
|
13
20
|
|
|
14
|
-
<!-- 选中状态显示端点黑色圆圈 -->
|
|
15
21
|
<g v-if="props.isSelected">
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
stroke-width="1"
|
|
22
|
+
<circle
|
|
23
|
+
v-if="adjustedWaypoints.length > 0"
|
|
24
|
+
:cx="adjustedWaypoints[0].x - bounds.minX + padding"
|
|
25
|
+
:cy="adjustedWaypoints[0].y - bounds.minY + padding"
|
|
26
|
+
r="4"
|
|
27
|
+
fill="#000000"
|
|
28
|
+
stroke="#FFFFFF"
|
|
29
|
+
stroke-width="1"
|
|
30
|
+
/>
|
|
31
|
+
<circle
|
|
32
|
+
v-if="adjustedWaypoints.length > 1"
|
|
33
|
+
:cx="adjustedWaypoints[adjustedWaypoints.length - 1].x - bounds.minX + padding"
|
|
34
|
+
:cy="adjustedWaypoints[adjustedWaypoints.length - 1].y - bounds.minY + padding"
|
|
35
|
+
r="4"
|
|
36
|
+
fill="#000000"
|
|
37
|
+
stroke="#FFFFFF"
|
|
38
|
+
stroke-width="1"
|
|
39
|
+
/>
|
|
24
40
|
</g>
|
|
25
41
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
:y="textPosition.y"
|
|
30
|
-
|
|
42
|
+
<text
|
|
43
|
+
v-if="lineName && lineName !== '' && EDGES_WITH_KEYWORDS.includes(shapeKey)"
|
|
44
|
+
:x="textPosition.x"
|
|
45
|
+
:y="textPosition.y"
|
|
46
|
+
text-anchor="middle"
|
|
47
|
+
dominant-baseline="middle"
|
|
48
|
+
font-family="思源黑体"
|
|
49
|
+
font-size="12"
|
|
50
|
+
fill="#5E5E5E"
|
|
51
|
+
style="pointer-events: none;"
|
|
52
|
+
>
|
|
31
53
|
{{ keywords }}{{ lineName }}
|
|
32
54
|
</text>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
55
|
+
<text
|
|
56
|
+
v-else-if="lineName && lineName !== ''"
|
|
57
|
+
:x="textPosition.x"
|
|
58
|
+
:y="textPosition.y"
|
|
59
|
+
text-anchor="middle"
|
|
60
|
+
dominant-baseline="middle"
|
|
61
|
+
font-family="思源黑体"
|
|
62
|
+
font-size="12"
|
|
63
|
+
fill="#5E5E5E"
|
|
64
|
+
style="pointer-events: none;"
|
|
65
|
+
>
|
|
36
66
|
{{ lineName }}
|
|
37
67
|
</text>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
68
|
+
<text
|
|
69
|
+
v-else-if="EDGES_WITH_KEYWORDS.includes(shapeKey)"
|
|
70
|
+
:x="textPosition.x"
|
|
71
|
+
:y="textPosition.y"
|
|
72
|
+
text-anchor="middle"
|
|
73
|
+
dominant-baseline="middle"
|
|
74
|
+
font-family="思源黑体"
|
|
75
|
+
font-size="12"
|
|
76
|
+
fill="#5E5E5E"
|
|
77
|
+
style="pointer-events: none;"
|
|
78
|
+
>
|
|
42
79
|
{{ keywords }}
|
|
43
80
|
</text>
|
|
44
81
|
</svg>
|
|
@@ -46,12 +83,17 @@
|
|
|
46
83
|
</template>
|
|
47
84
|
|
|
48
85
|
<script setup lang="ts">
|
|
49
|
-
import { computed
|
|
86
|
+
import { computed } from 'vue'
|
|
50
87
|
import type { Shape, Waypoint } from '../../types'
|
|
51
88
|
import LineStyleMarker from '../LineStyle/LineStyleMarker.vue'
|
|
52
|
-
import {
|
|
89
|
+
import {
|
|
90
|
+
DASHED_EDGE_SHAPES,
|
|
91
|
+
EDGES_WITH_KEYWORDS,
|
|
92
|
+
EDGES_WITH_ARROWHEADS,
|
|
93
|
+
DIAMOND_MARKER_SHAPES,
|
|
94
|
+
SPECIAL_END_POINT_SHAPES
|
|
95
|
+
} from '../../constants/edgeShapeKeys'
|
|
53
96
|
|
|
54
|
-
// Props
|
|
55
97
|
interface Props {
|
|
56
98
|
shape: Shape
|
|
57
99
|
isSelected?: boolean
|
|
@@ -61,12 +103,15 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
61
103
|
isSelected: false
|
|
62
104
|
})
|
|
63
105
|
|
|
64
|
-
// Events
|
|
65
106
|
const emit = defineEmits<{
|
|
66
107
|
'edge-click': [shape: Shape, event: MouseEvent]
|
|
67
108
|
}>()
|
|
68
109
|
|
|
69
|
-
|
|
110
|
+
const shapeKey = computed(() => props.shape.shapeKey || '')
|
|
111
|
+
const keywords = computed(() => props.shape.keywords || '')
|
|
112
|
+
const lineName = computed(() => props.shape.modelName || '')
|
|
113
|
+
|
|
114
|
+
// 解析 waypointId,统一转成路径点数组。
|
|
70
115
|
const waypoints = computed(() => {
|
|
71
116
|
if (!props.shape.waypointId) return []
|
|
72
117
|
|
|
@@ -74,7 +119,7 @@ const waypoints = computed(() => {
|
|
|
74
119
|
try {
|
|
75
120
|
return JSON.parse(props.shape.waypointId) as Waypoint[]
|
|
76
121
|
} catch (error) {
|
|
77
|
-
console.error('解析waypointId失败:', error)
|
|
122
|
+
console.error('解析 waypointId 失败:', error)
|
|
78
123
|
return []
|
|
79
124
|
}
|
|
80
125
|
}
|
|
@@ -86,14 +131,14 @@ const waypoints = computed(() => {
|
|
|
86
131
|
return []
|
|
87
132
|
})
|
|
88
133
|
|
|
89
|
-
//
|
|
134
|
+
// 根据路径点计算当前边的包围盒。
|
|
90
135
|
const bounds = computed(() => {
|
|
91
136
|
if (waypoints.value.length === 0) {
|
|
92
137
|
return { minX: 0, minY: 0, maxX: 100, maxY: 100 }
|
|
93
138
|
}
|
|
94
139
|
|
|
95
|
-
const xs = waypoints.value.map(wp => wp.x)
|
|
96
|
-
const ys = waypoints.value.map(wp => wp.y)
|
|
140
|
+
const xs = waypoints.value.map((wp) => wp.x)
|
|
141
|
+
const ys = waypoints.value.map((wp) => wp.y)
|
|
97
142
|
|
|
98
143
|
return {
|
|
99
144
|
minX: Math.min(...xs),
|
|
@@ -103,231 +148,189 @@ const bounds = computed(() => {
|
|
|
103
148
|
}
|
|
104
149
|
})
|
|
105
150
|
|
|
106
|
-
//
|
|
151
|
+
// SVG 容器需要给线头和选中圆点留出额外边距。
|
|
107
152
|
const padding = 10
|
|
108
153
|
const containerWidth = computed(() => {
|
|
109
154
|
const width = bounds.value.maxX - bounds.value.minX + padding * 2
|
|
110
|
-
// 如果宽度太小,设置最小宽度
|
|
111
155
|
return Math.max(width, 20)
|
|
112
156
|
})
|
|
113
157
|
const containerHeight = computed(() => bounds.value.maxY - bounds.value.minY + padding * 2)
|
|
114
|
-
const svgViewBox = computed(() =>
|
|
115
|
-
`0 0 ${containerWidth.value} ${containerHeight.value}`
|
|
116
|
-
)
|
|
158
|
+
const svgViewBox = computed(() => `0 0 ${containerWidth.value} ${containerHeight.value}`)
|
|
117
159
|
|
|
118
|
-
//
|
|
119
|
-
const
|
|
120
|
-
if (waypoints.value.length === 0) return
|
|
121
|
-
|
|
122
|
-
// 创建新数组以避免修改原始数据
|
|
123
|
-
const adjustedWaypoints = [...waypoints.value];
|
|
160
|
+
// 统一调整折点,保证 polyline、path 和选中态端点使用的是同一套坐标。
|
|
161
|
+
const adjustedWaypoints = computed(() => {
|
|
162
|
+
if (waypoints.value.length === 0) return []
|
|
124
163
|
|
|
125
|
-
|
|
126
|
-
if (DIAMOND_MARKER_SHAPES.includes(shapeKey.value) && adjustedWaypoints.length >= 2) {
|
|
127
|
-
const startPoint = adjustedWaypoints[0];
|
|
128
|
-
const nextPoint = adjustedWaypoints[1];
|
|
164
|
+
const nextWaypoints = [...waypoints.value]
|
|
129
165
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
const
|
|
166
|
+
// 调整起点位置,避免菱形起点标记被线条穿过。
|
|
167
|
+
if (DIAMOND_MARKER_SHAPES.includes(shapeKey.value) && nextWaypoints.length >= 2) {
|
|
168
|
+
const startPoint = nextWaypoints[0]
|
|
169
|
+
const nextPoint = nextWaypoints[1]
|
|
170
|
+
const dx = nextPoint.x - startPoint.x
|
|
171
|
+
const dy = nextPoint.y - startPoint.y
|
|
172
|
+
const length = Math.sqrt(dx * dx + dy * dy)
|
|
134
173
|
|
|
135
174
|
if (length > 0) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const shortenDistance = 18;
|
|
139
|
-
const ratio = shortenDistance / length;
|
|
175
|
+
const shortenDistance = 18
|
|
176
|
+
const ratio = shortenDistance / length
|
|
140
177
|
|
|
141
|
-
|
|
142
|
-
adjustedWaypoints[0] = {
|
|
178
|
+
nextWaypoints[0] = {
|
|
143
179
|
...startPoint,
|
|
144
180
|
x: startPoint.x + dx * ratio,
|
|
145
181
|
y: startPoint.y + dy * ratio
|
|
146
|
-
}
|
|
182
|
+
}
|
|
147
183
|
}
|
|
148
184
|
}
|
|
149
185
|
|
|
150
|
-
//
|
|
151
|
-
if (SPECIAL_END_POINT_SHAPES.includes(shapeKey.value) &&
|
|
152
|
-
const endPoint =
|
|
153
|
-
const prevPoint =
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const
|
|
157
|
-
const dy = prevPoint.y - endPoint.y;
|
|
158
|
-
const length = Math.sqrt(dx * dx + dy * dy);
|
|
186
|
+
// 调整终点位置,避免线条压进箭头或菱形终点里。
|
|
187
|
+
if (SPECIAL_END_POINT_SHAPES.includes(shapeKey.value) && nextWaypoints.length >= 2) {
|
|
188
|
+
const endPoint = nextWaypoints[nextWaypoints.length - 1]
|
|
189
|
+
const prevPoint = nextWaypoints[nextWaypoints.length - 2]
|
|
190
|
+
const dx = prevPoint.x - endPoint.x
|
|
191
|
+
const dy = prevPoint.y - endPoint.y
|
|
192
|
+
const length = Math.sqrt(dx * dx + dy * dy)
|
|
159
193
|
|
|
160
194
|
if (length > 0) {
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
const ratio = shortenDistance / length;
|
|
195
|
+
const shortenDistance = 14
|
|
196
|
+
const ratio = shortenDistance / length
|
|
164
197
|
|
|
165
|
-
|
|
166
|
-
adjustedWaypoints[adjustedWaypoints.length - 1] = {
|
|
198
|
+
nextWaypoints[nextWaypoints.length - 1] = {
|
|
167
199
|
...endPoint,
|
|
168
200
|
x: endPoint.x + dx * ratio,
|
|
169
201
|
y: endPoint.y + dy * ratio
|
|
170
|
-
}
|
|
202
|
+
}
|
|
171
203
|
}
|
|
172
204
|
}
|
|
173
205
|
|
|
174
|
-
return
|
|
175
|
-
.map(wp => `${wp.x - bounds.value.minX + padding},${wp.y - bounds.value.minY + padding}`)
|
|
176
|
-
.join(' ')
|
|
206
|
+
return nextWaypoints
|
|
177
207
|
})
|
|
178
208
|
|
|
179
|
-
//
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
const keywords = computed(() => props.shape.keywords || '')
|
|
183
|
-
|
|
184
|
-
//获取线的名称
|
|
185
|
-
const lineName = computed(() => props.shape.modelName || '')
|
|
186
|
-
|
|
209
|
+
// 普通边仍保持 polyline 渲染。
|
|
210
|
+
const linePoints = computed(() => {
|
|
211
|
+
if (adjustedWaypoints.value.length === 0) return '0,0 100,100'
|
|
187
212
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if (props.isSelected) {
|
|
192
|
-
return '#000000'
|
|
193
|
-
}
|
|
194
|
-
// 可以根据不同的形状类型返回不同的颜色
|
|
195
|
-
return '#5E5E5E'
|
|
196
|
-
})
|
|
197
|
-
const strokeWidth = computed(() => {
|
|
198
|
-
// 选中状态线条加粗
|
|
199
|
-
if (props.isSelected) {
|
|
200
|
-
return 2
|
|
201
|
-
}
|
|
202
|
-
return props.shape.style?.borderWidth || 1.5
|
|
203
|
-
})
|
|
204
|
-
const strokeDashArray = computed(() => {
|
|
205
|
-
if (DASHED_EDGE_SHAPES.includes(shapeKey.value)) {
|
|
206
|
-
return '12,11'; // 虚线样式
|
|
207
|
-
}
|
|
213
|
+
return adjustedWaypoints.value
|
|
214
|
+
.map((wp) => `${wp.x - bounds.value.minX + padding},${wp.y - bounds.value.minY + padding}`)
|
|
215
|
+
.join(' ')
|
|
208
216
|
})
|
|
209
217
|
|
|
210
|
-
//
|
|
218
|
+
// 计算文本位置,优先取中间线段的法线方向。
|
|
211
219
|
const textPosition = computed(() => {
|
|
212
|
-
if (!
|
|
213
|
-
|
|
214
|
-
return { x: 120, y: 40 };
|
|
220
|
+
if (!adjustedWaypoints.value || adjustedWaypoints.value.length === 0) {
|
|
221
|
+
return { x: 120, y: 40 }
|
|
215
222
|
}
|
|
216
223
|
|
|
217
|
-
if (
|
|
218
|
-
// 当只有一个路径点时,使用默认的向上偏移
|
|
224
|
+
if (adjustedWaypoints.value.length === 1) {
|
|
219
225
|
return {
|
|
220
|
-
x:
|
|
221
|
-
y:
|
|
222
|
-
}
|
|
226
|
+
x: adjustedWaypoints.value[0].x - bounds.value.minX + padding,
|
|
227
|
+
y: adjustedWaypoints.value[0].y - bounds.value.minY + padding - 10
|
|
228
|
+
}
|
|
223
229
|
}
|
|
224
230
|
|
|
225
|
-
|
|
226
|
-
let
|
|
231
|
+
let midPoint: { x: number; y: number }
|
|
232
|
+
let normalVector: { x: number; y: number }
|
|
227
233
|
|
|
228
|
-
if (
|
|
229
|
-
|
|
230
|
-
const
|
|
231
|
-
const
|
|
232
|
-
const p2 = waypoints.value[segmentIndex + 1];
|
|
234
|
+
if (adjustedWaypoints.value.length > 2) {
|
|
235
|
+
const segmentIndex = Math.floor((adjustedWaypoints.value.length - 1) / 2)
|
|
236
|
+
const p1 = adjustedWaypoints.value[segmentIndex]
|
|
237
|
+
const p2 = adjustedWaypoints.value[segmentIndex + 1]
|
|
233
238
|
|
|
234
|
-
// 计算中间线段的中点
|
|
235
239
|
midPoint = {
|
|
236
240
|
x: (p1.x + p2.x) / 2,
|
|
237
241
|
y: (p1.y + p2.y) / 2
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// 计算线段的方向向量
|
|
241
|
-
const dx = p2.x - p1.x;
|
|
242
|
-
const dy = p2.y - p1.y;
|
|
242
|
+
}
|
|
243
243
|
|
|
244
|
-
|
|
245
|
-
const
|
|
244
|
+
const dx = p2.x - p1.x
|
|
245
|
+
const dy = p2.y - p1.y
|
|
246
|
+
const length = Math.sqrt(dx * dx + dy * dy)
|
|
246
247
|
|
|
247
|
-
// 计算单位法线向量(向左旋转90度)
|
|
248
248
|
if (length > 0) {
|
|
249
249
|
normalVector = {
|
|
250
250
|
x: -dy / length,
|
|
251
251
|
y: dx / length
|
|
252
|
-
}
|
|
252
|
+
}
|
|
253
253
|
} else {
|
|
254
|
-
|
|
255
|
-
normalVector = { x: 0, y: -1 };
|
|
254
|
+
normalVector = { x: 0, y: -1 }
|
|
256
255
|
}
|
|
257
256
|
} else {
|
|
258
|
-
|
|
259
|
-
const
|
|
260
|
-
const p2 = waypoints.value[1];
|
|
257
|
+
const p1 = adjustedWaypoints.value[0]
|
|
258
|
+
const p2 = adjustedWaypoints.value[1]
|
|
261
259
|
|
|
262
|
-
// 计算中点
|
|
263
260
|
midPoint = {
|
|
264
261
|
x: (p1.x + p2.x) / 2,
|
|
265
262
|
y: (p1.y + p2.y) / 2
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// 计算方向向量
|
|
269
|
-
const dx = p2.x - p1.x;
|
|
270
|
-
const dy = p2.y - p1.y;
|
|
263
|
+
}
|
|
271
264
|
|
|
272
|
-
|
|
273
|
-
const
|
|
265
|
+
const dx = p2.x - p1.x
|
|
266
|
+
const dy = p2.y - p1.y
|
|
267
|
+
const length = Math.sqrt(dx * dx + dy * dy)
|
|
274
268
|
|
|
275
|
-
// 计算单位法线向量
|
|
276
269
|
if (length > 0) {
|
|
277
270
|
normalVector = {
|
|
278
271
|
x: -dy / length,
|
|
279
272
|
y: dx / length
|
|
280
|
-
}
|
|
273
|
+
}
|
|
281
274
|
} else {
|
|
282
|
-
normalVector = { x: 0, y: -1 }
|
|
275
|
+
normalVector = { x: 0, y: -1 }
|
|
283
276
|
}
|
|
284
277
|
}
|
|
285
278
|
|
|
286
|
-
|
|
287
|
-
const
|
|
288
|
-
const
|
|
289
|
-
const adjustedY = midPoint.y + normalVector.y * offsetDistance;
|
|
279
|
+
const offsetDistance = 10
|
|
280
|
+
const adjustedX = midPoint.x + normalVector.x * offsetDistance
|
|
281
|
+
const adjustedY = midPoint.y + normalVector.y * offsetDistance
|
|
290
282
|
|
|
291
|
-
// 转换为相对坐标
|
|
292
283
|
return {
|
|
293
284
|
x: adjustedX - bounds.value.minX + padding,
|
|
294
285
|
y: adjustedY - bounds.value.minY + padding
|
|
295
|
-
}
|
|
296
|
-
})
|
|
286
|
+
}
|
|
287
|
+
})
|
|
288
|
+
|
|
289
|
+
const edgeColor = computed(() => {
|
|
290
|
+
if (props.isSelected) {
|
|
291
|
+
return '#000000'
|
|
292
|
+
}
|
|
293
|
+
return '#5E5E5E'
|
|
294
|
+
})
|
|
295
|
+
|
|
296
|
+
const strokeWidth = computed(() => {
|
|
297
|
+
if (props.isSelected) {
|
|
298
|
+
return 2
|
|
299
|
+
}
|
|
300
|
+
return props.shape.style?.borderWidth || 1.5
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
const strokeDashArray = computed(() => {
|
|
304
|
+
if (DASHED_EDGE_SHAPES.includes(shapeKey.value)) {
|
|
305
|
+
return '12,11'
|
|
306
|
+
}
|
|
307
|
+
})
|
|
297
308
|
|
|
298
|
-
// 获取起点标记
|
|
299
309
|
const getMarkerStart = () => {
|
|
300
|
-
// 菱形标记
|
|
301
310
|
if (DIAMOND_MARKER_SHAPES.includes(shapeKey.value)) {
|
|
302
|
-
return `url(#diamond-${shapeKey.value})
|
|
311
|
+
return `url(#diamond-${shapeKey.value})`
|
|
303
312
|
}
|
|
304
313
|
return ''
|
|
305
314
|
}
|
|
306
315
|
|
|
307
|
-
// 获取终点标记
|
|
308
316
|
const getMarkerEnd = () => {
|
|
309
|
-
// 空心箭头
|
|
310
317
|
if (EDGES_WITH_ARROWHEADS.includes(shapeKey.value)) {
|
|
311
|
-
return `url(#arrowhead-${shapeKey.value})
|
|
318
|
+
return `url(#arrowhead-${shapeKey.value})`
|
|
312
319
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
return `url(#diamond-${shapeKey.value})`;
|
|
320
|
+
if (SPECIAL_END_POINT_SHAPES.includes(shapeKey.value)) {
|
|
321
|
+
return `url(#diamond-${shapeKey.value})`
|
|
316
322
|
}
|
|
317
323
|
return ''
|
|
318
324
|
}
|
|
319
325
|
|
|
320
|
-
// 事件处理
|
|
321
326
|
const handleClick = (event: MouseEvent) => {
|
|
322
|
-
console.log('Edge组件内部捕获到点击事件:', props.shape.id, props.shape.shapeType)
|
|
323
|
-
// 确保shapeType为edge
|
|
327
|
+
console.log('Edge组件内部捕获到点击事件:', props.shape.id, props.shape.shapeType)
|
|
324
328
|
const shapeWithCorrectType = {
|
|
325
329
|
...props.shape,
|
|
326
330
|
shapeType: 'edge' as const
|
|
327
|
-
}
|
|
331
|
+
}
|
|
328
332
|
emit('edge-click', shapeWithCorrectType, event)
|
|
329
333
|
}
|
|
330
|
-
|
|
331
334
|
</script>
|
|
332
335
|
|
|
333
336
|
<style scoped>
|
|
@@ -352,4 +355,4 @@ const handleClick = (event: MouseEvent) => {
|
|
|
352
355
|
.edge-svg circle {
|
|
353
356
|
pointer-events: none;
|
|
354
357
|
}
|
|
355
|
-
</style
|
|
358
|
+
</style>
|