rh-vue3-snakerflow-designer
Version:
情怀!N年前使用的工作流引擎,虽然原作者已经不再维护,但是还是有那么一波人还在使用。个人看来其核心功能尚好,麻雀虽少,五脏俱全,是用来学习工作流引擎的好项目。但其流程设计器所用的技术栈可能就跟不上时代了(2016年前的开源项目)。为了让大伙或自己用得更舒心,或者也为了让更多人认识或重新认识这个工作流引擎。本人就花些许时间,使用现阶段前端主流的技术栈重新开发此款流程设计器。如大家在使用的过程中如有啥问题,欢迎留言或进群交流!
84 lines (75 loc) • 1.72 kB
text/typescript
import { CircleNode, CircleNodeModel, ConnectRule, GraphModel, h, NodeConfig } from '@logicflow/core'
import { nodeStyleHandle } from '../tool'
class EndModel extends CircleNodeModel {
static extendKey = 'EndModel';
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)
}
setAttributes ():void {
this.r = 18
}
getConnectedSourceRules (): ConnectRule[] {
const rules = super.getConnectedSourceRules()
const notAsSource = {
message: '结束节点不能作为边的起点',
validate: () => false
}
rules.push(notAsSource)
return rules
}
getNodeStyle () : {
[x: string]: any;
r?: number;
fill?: string;
stroke?: string;
strokeWidth?: number;
} {
const style = super.getNodeStyle()
style.fill = '#ffffff'
style.stroke = '#2c89ff'
return nodeStyleHandle(this, style)
}
}
class EndView extends CircleNode {
static extendKey = 'EndView';
getAnchorStyle (): {} {
return {
visibility: 'hidden'
}
}
getShape ():h.JSX.Element {
const { model } = this.props
const style = model.getNodeStyle()
style.fill = '#2c89ff'
const { x, y, r } = model
const outCircle = super.getShape()
return h(
'g',
{},
outCircle,
h('circle', {
...style,
cx: x,
cy: y,
r: r - 5
})
)
}
}
const End = {
type: 'snaker:end',
view: EndView,
model: EndModel
}
export { EndView, EndModel }
export default End