File tree Expand file tree Collapse file tree 7 files changed +149
-6
lines changed Expand file tree Collapse file tree 7 files changed +149
-6
lines changed Original file line number Diff line number Diff line change @@ -37,13 +37,105 @@ export default {
37
37
this .lf .render ({
38
38
nodes: [
39
39
{
40
+ id: ' node_1' ,
40
41
type: ' start-node' ,
41
42
x: 220 ,
42
43
y: 200 ,
43
- text: ' 开始'
44
+ text: ' start'
45
+ },
46
+ {
47
+ id: ' node_2' ,
48
+ type: ' fetch-node' ,
49
+ x: 420 ,
50
+ y: 200 ,
51
+ text: ' fetch data'
52
+ },
53
+ {
54
+ id: ' node_3' ,
55
+ type: ' function-node' ,
56
+ x: 620 ,
57
+ y: 200 ,
58
+ text: ' function'
59
+ },
60
+ {
61
+ id: ' node_4' ,
62
+ type: ' delay-node' ,
63
+ x: 420 ,
64
+ y: 300 ,
65
+ text: ' function'
66
+ },
67
+ {
68
+ id: ' node_5' ,
69
+ type: ' switch-node' ,
70
+ x: 820 ,
71
+ y: 200 ,
72
+ text: ' switch'
73
+ },
74
+ {
75
+ id: ' node_6' ,
76
+ type: ' function-node' ,
77
+ x: 1020 ,
78
+ y: 200 ,
79
+ text: ' function'
80
+ },
81
+ {
82
+ id: ' node_7' ,
83
+ type: ' function-node' ,
84
+ x: 1020 ,
85
+ y: 300 ,
86
+ text: ' function'
87
+ },
88
+ ],
89
+ edges: [
90
+ {
91
+ type: ' flow-link' ,
92
+ sourceNodeId: ' node_1' ,
93
+ targetNodeId: ' node_2'
94
+ },
95
+ {
96
+ type: ' flow-link' ,
97
+ sourceNodeId: ' node_2' ,
98
+ targetNodeId: ' node_3'
99
+ },
100
+ {
101
+ type: ' flow-link' ,
102
+ sourceNodeId: ' node_3' ,
103
+ startPoint: {
104
+ x: 680 ,
105
+ y: 200
106
+ },
107
+ targetNodeId: ' node_4'
108
+ },
109
+ {
110
+ type: ' flow-link' ,
111
+ sourceNodeId: ' node_4' ,
112
+ startPoint: {
113
+ x: 360 ,
114
+ y: 300
115
+ },
116
+ targetNodeId: ' node_2'
117
+ },
118
+ {
119
+ type: ' flow-link' ,
120
+ sourceNodeId: ' node_3' ,
121
+ targetNodeId: ' node_5'
122
+ },
123
+ {
124
+ type: ' flow-link' ,
125
+ sourceNodeId: ' node_5' ,
126
+ targetNodeId: ' node_6'
127
+ },
128
+ {
129
+ type: ' flow-link' ,
130
+ sourceNodeId: ' node_5' ,
131
+ targetNodeId: ' node_7'
44
132
},
45
133
]
46
134
})
135
+ this .lf .on (' node-red:start' , () => {
136
+ // todo: 让流程跑起来
137
+ console .log (' 我要开始执行流程了' )
138
+ })
47
139
}
48
140
}
49
141
</script >
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import FunctionNode from "./nodes/FunctionNode";
3
3
import SwitchNode from "./nodes/SwitchNode" ;
4
4
import StartNode from "./nodes/StartNode" ;
5
5
import FetchNode from "./nodes/FetchNode" ;
6
+ import DelayNode from "./nodes/DelayNode" ;
6
7
import FlowLink from "./FlowLink" ;
7
8
import Palette from './tools/Palette.vue' ;
8
9
@@ -14,6 +15,7 @@ class NodeRedExtension {
14
15
lf . register ( StartNode ) ;
15
16
lf . register ( FetchNode ) ;
16
17
lf . register ( FlowLink ) ;
18
+ lf . register ( DelayNode ) ;
17
19
lf . setDefaultEdgeType ( 'flow-link' ) ;
18
20
this . app = createApp ( Palette , {
19
21
lf
@@ -23,9 +25,7 @@ class NodeRedExtension {
23
25
const node = document . createElement ( 'div' )
24
26
node . className = 'node-red-palette'
25
27
domOverlay . appendChild ( node )
26
- setTimeout ( ( ) => {
27
- this . app . mount ( node )
28
- } )
28
+ this . app . mount ( node )
29
29
}
30
30
}
31
31
Original file line number Diff line number Diff line change
1
+ import { h } from '@logicflow/core'
2
+ import BaseNode from "./BaseNode"
3
+
4
+ class DelayNode extends BaseNode . view {
5
+ getIcon ( ) {
6
+ const {
7
+ width,
8
+ height,
9
+ } = this . props . model ;
10
+ return h ( 'image' , {
11
+ width : 30 ,
12
+ height : 30 ,
13
+ x : - width / 2 ,
14
+ y : - height / 2 ,
15
+ href : 'images/delay.svg'
16
+ } )
17
+ }
18
+ }
19
+
20
+ class DelayNodeModel extends BaseNode . model {
21
+ getNodeStyle ( ) {
22
+ const style = super . getNodeStyle ( )
23
+ style . fill = 'rgb(230, 224, 248)' ;
24
+ return style
25
+ }
26
+ }
27
+
28
+ export default {
29
+ type : 'delay-node' ,
30
+ model : DelayNodeModel ,
31
+ view : DelayNode
32
+ }
Original file line number Diff line number Diff line change @@ -3,16 +3,21 @@ import BaseNode from "./BaseNode"
3
3
4
4
class StartNode extends BaseNode . view {
5
5
getIcon ( ) {
6
+ const { model, graphModel } = this . props ;
6
7
const {
7
8
width,
8
9
height,
9
- } = this . props . model ;
10
+ } = model ;
10
11
return h ( 'image' , {
11
12
width : 30 ,
12
13
height : 30 ,
13
14
x : - width / 2 ,
14
15
y : - height / 2 ,
15
- href : 'images/start.svg'
16
+ className : 'node-red-start' ,
17
+ href : 'images/start.svg' ,
18
+ onClick : ( ) => {
19
+ graphModel . eventCenter . emit ( 'node-red:start' )
20
+ }
16
21
} )
17
22
}
18
23
}
Original file line number Diff line number Diff line change 16
16
position : absolute;
17
17
left : 0px ;
18
18
top : 0px ;
19
+ }
20
+ .node-red-start {
21
+ cursor : pointer;
22
+ pointer-events : all;
19
23
}
Original file line number Diff line number Diff line change @@ -61,6 +61,12 @@ const baseNodes = ref([
61
61
text: ' switch' ,
62
62
background: ' rgb(226, 217, 110)' ,
63
63
icon: ' public/images/switch.svg'
64
+ },
65
+ {
66
+ type: ' delay-node' ,
67
+ text: ' delay' ,
68
+ background: ' rgb(230, 224, 248)' ,
69
+ icon: ' public/images/delay.svg'
64
70
}
65
71
])
66
72
@@ -69,6 +75,9 @@ const baseNodes = ref([
69
75
.demo-collapse {
70
76
width : 150px ;
71
77
}
78
+ .demo-collapse /deep/ .el-collapse-item__header {
79
+ text-indent : 20px ;
80
+ }
72
81
.red-ui-palette-node {
73
82
cursor : move ;
74
83
background : #fff ;
You can’t perform that action at this time.
0 commit comments