Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4363e0a

Browse files
committed
feat: add vue html node
1 parent a776535 commit 4363e0a

File tree

5 files changed

+87
-1
lines changed

5 files changed

+87
-1
lines changed

‎src/components/FlowChart.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ export default {
8585
y: 300,
8686
text: 'function'
8787
},
88+
{
89+
id: 'node_8',
90+
type: 'vue-html',
91+
x: 400,
92+
y: 100
93+
}
8894
],
8995
edges: [
9096
{
@@ -129,13 +135,18 @@ export default {
129135
type: 'flow-link',
130136
sourceNodeId: 'node_5',
131137
targetNodeId: 'node_7'
132-
},
138+
}
133139
]
134140
})
135141
this.lf.on('node-red:start', () => {
136142
// todo: 让流程跑起来
137143
console.log('我要开始执行流程了')
138144
})
145+
this.lf.on('vue-node:click', (data ) => {
146+
this.lf.setProperties(data.id, {
147+
t: ++data.val
148+
})
149+
})
139150
}
140151
}
141152
</script>

‎src/components/node-red/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import FetchNode from "./nodes/FetchNode";
66
import DelayNode from "./nodes/DelayNode";
77
import FlowLink from "./FlowLink";
88
import Palette from './tools/Palette.vue';
9+
import VueHtmlNode from './nodes/VueHtmlNode';
910

1011
class NodeRedExtension {
1112
static pluginName = 'NodeRedExtension'
@@ -16,6 +17,7 @@ class NodeRedExtension {
1617
lf.register(FetchNode);
1718
lf.register(FlowLink);
1819
lf.register(DelayNode);
20+
lf.register(VueHtmlNode);
1921
lf.setDefaultEdgeType('flow-link');
2022
this.app = createApp(Palette, {
2123
lf
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { HtmlNode, HtmlNodeModel } from "@logicflow/core";
2+
import { createApp } from 'vue';
3+
import VueNode from './VueNode.vue';
4+
5+
class VueHtmlNode extends HtmlNode {
6+
constructor (props) {
7+
super(props)
8+
this.app = createApp(VueNode)
9+
}
10+
setHtml(rootEl) {
11+
const node = document.createElement('div')
12+
const { model, graphModel } = this.props;
13+
const properties = model.getProperties();
14+
rootEl.appendChild(node)
15+
if (!this.isMounted) {
16+
this.app.mount(node)
17+
this.app._instance.emitsOptions['btn:click'] = (val) => {
18+
graphModel.eventCenter.emit('vue-node:click', {
19+
id: model.id,
20+
val
21+
})
22+
}
23+
this.isMounted = true
24+
} else {
25+
this.app._instance.props.properties = properties
26+
}
27+
}
28+
}
29+
30+
class VueHtmlNodeModel extends HtmlNodeModel {
31+
setAttributes() {
32+
this.width = 300;
33+
this.height = 32;
34+
this.text.editable = false;
35+
}
36+
getOutlineStyle() {
37+
const style = super.getOutlineStyle();
38+
style.stroke = 'none';
39+
style.hover.stroke = 'none';
40+
return style;
41+
}
42+
getDefaultAnchor() {
43+
return []
44+
}
45+
}
46+
47+
export default {
48+
type: 'vue-html',
49+
model: VueHtmlNodeModel,
50+
view: VueHtmlNode
51+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<template>
2+
<div class="demo-collapse">
3+
<el-button @click="$emit('btn:click', properties.t)">vue_html_node: click_me_{{properties.t}}</el-button>
4+
</div>
5+
</template>
6+
7+
<script>
8+
export default {
9+
props: {
10+
properties: {
11+
type: Object,
12+
default: () => ({
13+
t: 1
14+
})
15+
},
16+
},
17+
emits: ['btn:click']
18+
}
19+
</script>
20+
<style scoped>
21+
22+
</style>

‎src/components/node-red/tools/Setting.vue

Whitespace-only changes.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /