@@ -85,10 +85,12 @@ const emits = defineEmits<{
85
85
const processNodeTree = useWatchNode (props )
86
86
87
87
provide (' readonly' , props .readonly )
88
+
89
+ // TODO 可优化:拖拽有点卡顿
90
+ /** 拖拽、放大缩小等操作 */
88
91
let scaleValue = ref (100 )
89
92
const MAX_SCALE_VALUE = 200
90
93
const MIN_SCALE_VALUE = 50
91
-
92
94
const isDragging = ref (false )
93
95
const startX = ref (0 )
94
96
const startY = ref (0 )
@@ -128,10 +130,33 @@ const stopDrag = () => {
128
130
resetCursor () // 重置光标
129
131
}
130
132
133
+ const zoomIn = () => {
134
+ if (scaleValue .value == MAX_SCALE_VALUE ) {
135
+ return
136
+ }
137
+ scaleValue .value += 10
138
+ }
139
+
140
+ const zoomOut = () => {
141
+ if (scaleValue .value == MIN_SCALE_VALUE ) {
142
+ return
143
+ }
144
+ scaleValue .value -= 10
145
+ }
146
+
147
+ const processReZoom = () => {
148
+ scaleValue .value = 100
149
+ }
150
+
151
+ const resetPosition = () => {
152
+ currentX .value = initialX .value
153
+ currentY .value = initialY .value
154
+ }
155
+
156
+ /** 校验节点设置 */
131
157
const errorDialogVisible = ref (false )
132
158
let errorNodes: SimpleFlowNode [] = []
133
159
134
- // 校验节点设置。 暂时以 showText 为空 未节点错误配置
135
160
const validateNode = (node : SimpleFlowNode | undefined , errorNodes : SimpleFlowNode []) => {
136
161
if (node ) {
137
162
const { type, showText, conditionNodes } = node
@@ -212,37 +237,11 @@ const importLocalFile = () => {
212
237
}
213
238
}
214
239
215
- // 放大
216
- const zoomIn = () => {
217
- if (scaleValue .value == MAX_SCALE_VALUE ) {
218
- return
219
- }
220
- scaleValue .value += 10
221
- }
222
-
223
- // 缩小
224
- const zoomOut = () => {
225
- if (scaleValue .value == MIN_SCALE_VALUE ) {
226
- return
227
- }
228
- scaleValue .value -= 10
229
- }
230
-
231
- const processReZoom = () => {
232
- scaleValue .value = 100
233
- }
234
-
235
240
// 在组件初始化时记录初始位置
236
241
onMounted (() => {
237
242
initialX .value = currentX .value
238
243
initialY .value = currentY .value
239
244
})
240
-
241
- // 重置位置的函数
242
- const resetPosition = () => {
243
- currentX .value = initialX .value
244
- currentY .value = initialY .value
245
- }
246
245
</script >
247
246
248
247
<style lang="scss" scoped>
0 commit comments