rh-vue3-snakerflow-designer
Version:
情怀!N年前使用的工作流引擎,虽然原作者已经不再维护,但是还是有那么一波人还在使用。个人看来其核心功能尚好,麻雀虽少,五脏俱全,是用来学习工作流引擎的好项目。但其流程设计器所用的技术栈可能就跟不上时代了(2016年前的开源项目)。为了让大伙或自己用得更舒心,或者也为了让更多人认识或重新认识这个工作流引擎。本人就花些许时间,使用现阶段前端主流的技术栈重新开发此款流程设计器。如大家在使用的过程中如有啥问题,欢迎留言或进群交流!
82 lines (76 loc) • 2.54 kB
text/typescript
import { GraphModel, h, NodeConfig, PolygonNode, PolygonNodeModel } from '@logicflow/core'
import { nodeStyleHandle } from '../tool'
class ForkModel extends PolygonNodeModel {
static extendKey = 'ForkModel';
constructor (data: NodeConfig, graphModel: GraphModel) {
if (!data.text) {
data.text = ''
}
if (data.text && typeof data.text === 'string') {
data.text = {
value: data.text,
x: data.x,
y: data.y + 40
}
}
super(data, graphModel)
this.points = [
[25, 0],
[50, 25],
[25, 50],
[0, 25]
]
}
getNodeStyle (): {
[x: string]: any;
fill?: string;
stroke?: string;
strokeWidth?: number;
} {
const style = super.getNodeStyle()
style.fill = '#ffffff'
style.stroke = '#efb339'
return nodeStyleHandle(this, style)
}
}
class ForkView extends PolygonNode {
static extendKey = 'ForkNode';
getShape (): h.JSX.Element {
const { model } = this.props
const { x, y, width, height, points } = model
const style = model.getNodeStyle()
return h(
'g',
{
transform: `matrix(1 0 0 1 ${x - width / 2} ${y - height / 2})`
},
h('polygon', {
...style,
x,
y,
points
}),
h(
'svg',
{
x: (width - 28) / 2,
y: (height - 28) / 2,
width: 28,
height: 28,
viewBox: '0 0 1024 1024'
},
h('path', {
fill: style.stroke,
d: 'M779.733333 64c2.474667 0 4.864 0.768 6.826667 2.176l192.042667 137.173333a11.733333 11.733333 0 0 1 0 19.114667l-192 137.173333A11.733333 11.733333 0 0 1 768 350.08L767.957333 256h-237.994666c-6.826667 0-14.250667 7.466667-15.786667 18.901333l-0.298667 4.48v465.237334c0 12.373333 6.613333 21.248 13.482667 23.04l2.56 0.341333H768L768 674.346667a11.733333 11.733333 0 0 1 18.56-9.557334l192.042667 137.173334a11.733333 11.733333 0 0 1 0 19.114666l-192 137.173334a11.733333 11.733333 0 0 1-18.602667-9.557334L767.957333 853.333333h-237.994666c-54.912 0-97.877333-45.824-101.205334-101.717333l-0.213333-6.997333L428.501333 554.666667H291.370667a128.042667 128.042667 0 1 1 0-85.333334h137.130666V279.381333c0-56.618667 40.789333-104.704 94.677334-108.458666L529.92 170.666667h237.994667L768 75.733333c0-6.485333 5.248-11.733333 11.733333-11.733333z'
})
)
)
}
}
const Fork = {
type: 'snaker:fork',
view: ForkView,
model: ForkModel
}
export { ForkView, ForkModel }
export default Fork