release.vue
2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!--
* @Date: 2025-03-10 16:52:35
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-03-19 11:32:33
* @FilePath: /logic-flow2/src/views/release.vue
* @Description: 拖拽面板
-->
<template>
<div class="container">
<div ref="container" class="flow-container"></div>
</div>
</template>
<script setup>
import LogicFlow from "@logicflow/core";
const container = ref(null);
let lf = null;
onMounted(() => {
lf = new LogicFlow({
container: container.value,
grid: true,
nodeTextDraggable: true,
nodeTextEdit: true,
edgeTextEdit: true,
stopScrollGraph: true,
stopZoomGraph: false,
style: {
rect: {
width: 100,
height: 50,
radius: 8,
},
circle: {
r: 30,
},
},
});
lf.render({
nodes: [
{
id: "start",
type: "rect",
x: 200,
y: 100,
text: "开始",
properties: {
nodeType: "start",
style: {
fill: "#e8f7ff",
stroke: "#1890ff",
strokeWidth: 2,
},
textStyle: {
color: "#1890ff",
fontSize: 16,
fontWeight: "bold",
},
},
},
{
id: "process",
type: "circle",
x: 400,
y: 100,
text: "处理",
properties: {
nodeType: "process",
style: {
fill: "#fff7e6",
stroke: "#ffa940",
strokeWidth: 2,
},
},
},
],
edges: [
{
id: "edge1",
sourceNodeId: "start",
targetNodeId: "process",
type: "polyline",
text: "流转",
properties: {
style: {
stroke: "#1890ff",
strokeWidth: 2,
},
},
},
],
});
// 监听节点点击
lf.on("node:click", ({ data }) => {
console.log("点击节点:", data);
});
// 监听连线完成
lf.on("edge:connect", ({ data }) => {
console.log("连线完成:", data);
});
// 监听画布缩放
lf.on("graph:transform", (transform) => {
console.log("画布变换:", transform);
});
// 居中显示
lf.translateCenter();
});
</script>
<style scoped>
.container {
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
}
.flow-container {
flex: 1;
width: 100%;
height: 100%;
}
</style>