logicFlow 流程图编辑工具使用及开源地址

news2024/10/6 18:25:43

一、工具介绍

LogicFlow 是一款流程图编辑框架,提供了一系列流程图交互、编辑所必需的功能和灵活的节点自定义、插件等拓展机制。LogicFlow 支持前端研发自定义开发各种逻辑编排场景,如流程图、ER 图、BPMN 流程等。在工作审批配置、机器人逻辑编排、无代码平台流程配置都有较好的应用。
更多资料请查看LogicFlow 系列文章

二、vue3 + vite + tsx 基本使用

1、插件引入

npm install @logicflow/core
npm install @logicflow/extension

2、页面使用

import LogicFlow from "@logicflow/core";
import "@logicflow/core/dist/style/index.css";

const lf = new LogicFlow({
  container: document.querySelector("#app"),
  grid: true,
});

lf.render({
  nodes: [
    {
      id: "1",
      type: "rect",
      x: 100,
      y: 100,
      text: "节点1",
    },
    {
      id: "2",
      type: "circle",
      x: 300,
      y: 200,
      text: "节点2",
    },
  ],
  edges: [
    {
      sourceNodeId: "1",
      targetNodeId: "2",
      type: "polyline",
      text: "连线",
    },
  ],
});

 

三、使用 bpmn 元素
1、

2、

四、自定义节点

1、基于基本节点的重新自定义
如下图,如果需要重新开发任务节点、或者新增一个并行网关,就需要去重新定义新节点
在这里插入图片描述

(1)自定义用户任务(rect)
在这里插入图片描述

// eslint-disable-next-line max-classes-per-file
import Ids from 'ids'
// eslint-disable-next-line max-classes-per-file
export default function registerUserTask(lf: any) {
    const NODE_COLOR = '#187dff'
    // 多实例展示
    const matterOptions = {
        // 循环事件
        circleMatter:
            'M512.272 139.637V0L326.09 186.182l186.182 186.181V232.728c153.6 0 279.272 125.673 279.272 279.272 0 46.545-13.963 93.09-32.582 130.328l69.818 69.817c32.582-60.508 55.854-125.673 55.854-200.145 0.001-204.8-167.562-372.363-372.362-372.363z m0 651.635c-153.6 0-279.273-125.673-279.273-279.272 0-46.546 13.964-93.09 32.583-130.328l-69.818-69.817C163.182 372.363 139.91 437.528 139.91 512c0 204.8 167.563 372.363 372.363 372.363V1024l186.182-186.182-186.182-186.181v139.635z',
        // 并行多重事件
        parallelMatter:
            'M256 174.08v614.4h102.4v-614.4H256z m204.8 0v614.4h102.4v-614.4H460.8z m204.8 0v614.4h102.4v-614.4H665.6z',
        // 时序多重事件
        timingMatter:
            'M204.8 225.28v102.4h614.4v-102.4H204.8z m0 204.8v102.4h614.4v-102.4H204.8z m0 204.8v102.4h614.4v-102.4H204.8z',
    }
    const ids = new Ids([32, 32, 1])
    lf.register('bpmn:userTask', ({ RectNode, RectNodeModel, h }) => {
        class View extends RectNode {
            getIconShape() {
                const { model } = this.props
                const { x, y, width, height } = model
                const { instanceType } = model.getProperties()
                const type = matterOptions[instanceType]
                return [
                  // 左上角svg图标
                    h(
                        'svg',
                        {
                            x: x - width / 2 + 5,
                            y: y - height / 2 + 5,
                            width: 20,
                            height: 20,
                            viewBox: '0 0 1222 1024',
                        },
                        h('path', {
                            fill: NODE_COLOR,
                            d: 'M892.8 737.122c-20.8-49.2-50.6-93.4-88.5-131.3-37.9-37.9-82.1-67.7-131.3-88.5-11-4.7-22.2-8.8-33.5-12.5 63.3-40.6 105.2-111.6 105.2-192.3 0-126.1-102.2-228.3-228.3-228.3s-228.5 102.1-228.5 228.2c0 79.6 40.7 149.6 102.4 190.5-13.3 4.1-26.4 8.9-39.3 14.3-49.2 20.8-93.4 50.6-131.3 88.5-37.9 37.9-67.7 82.1-88.5 131.3-21.6 51-32.5 105.1-32.5 160.9v48H925.3v-48c0-55.7-11-109.8-32.5-160.8z',
                        })
                    ),
                    // 底部中间svg图标
                    h(
                        'svg',
                        {
                            x: x - width / 2 + 38,
                            y: y + height / 2 - 27,
                            width: 25,
                            height: 25,
                            viewBox: '0 0 1274 1024',
                        },
                        h('path', {
                            fill: NODE_COLOR,
                            d: type,
                        })
                    ),
                ]
            }

            getShape() {
                const { model } = this.props
                const { x, y, width, height, radius } = model
                const style = model.getNodeStyle()
                return h('g', {}, [
                    h('rect', {
                        ...style,
                        x: x - width / 2,
                        y: y - height / 2,
                        rx: radius,
                        ry: radius,
                        width,
                        height,
                    }),
                    ...this.getIconShape(),
                ])
            }
        }

        class Model extends RectNodeModel {
            constructor(data, graphModel) {
              // 修改自定义节点id
                if (!data.id) data.id = `UserTask_${ids.next()}`
                data.text = {
                    value: (data.text && data.text.value) || '',
                    x: data.x,
                    y: data.y + 50,
                }
                super(data, graphModel)
            }

            initNodeData(data) {
                super.initNodeData(data)
                const length = 80
                this.points = [
                    [0, 0],
                    [length + 20, 0],
                    [length + 20, length],
                    [0, length],
                ]
            }

            // 自定义锚点样式
            getAnchorStyle() {
                const style = super.getAnchorStyle()
                style.hover.r = 8
                style.hover.fill = 'rgb(24, 125, 255)'
                style.hover.stroke = 'rgb(24, 125, 255)'
                return style
            }

            getNodeStyle() {
                const style = super.getNodeStyle()
                style.stroke = NODE_COLOR
                return style
            }
        }

        return {
            view: View,
            model: Model,
        }
    })
}

(2)自定义并行网关(polygon)
在这里插入图片描述


// eslint-disable-next-line max-classes-per-file
import Ids from 'ids'

// eslint-disable-next-line max-classes-per-file
const NODE_COLOR: string = '#187dff'
export default function registerParallelGateway(lf: any) {
    const ids = new Ids([32, 32, 1])
    lf.register(
        'bpmn:parallelGateway',
        ({
            PolygonNode,
            PolygonNodeModel,
            h,
        }: {
            PolygonNode: any
            PolygonNodeModel: any
            h: any
        }) => {
            // 继承 logicFLow的多边形节点
            class Node extends PolygonNode {
                // eslint-disable-next-line class-methods-use-this
                getIconShape() {
                    // h方法是 LogicFlow 对外暴露的渲染函数
                    return h(
                        'svg',
                        {
                            x: 14,
                            y: 13,
                            width: 23,
                            height: 23,
                            viewBox: '0 0 1024 1024',
                        },
                        h('path', {
                            fill: NODE_COLOR,
                            d: 'M1024 592V432c0-8.8-7.2-16-16-16H624c-8.8 0-16-7.2-16-16V16c0-8.8-7.2-16-16-16H432c-8.8 0-16 7.2-16 16v384c0 8.8-7.2 16-16 16H16c-8.8 0-16 7.2-16 16v160c0 8.8 7.2 16 16 16h384c8.8 0 16 7.2 16 16v384c0 8.8 7.2 16 16 16h160c8.8 0 16-7.2 16-16V624c0-8.8 7.2-16 16-16h384c8.8 0 16-7.2 16-16zM536 960h-48c-4.4 0-8-3.6-8-8V560c0-8.8-7.2-16-16-16H72c-4.4 0-8-3.6-8-8v-48c0-4.4 3.6-8 8-8h392c8.8 0 16-7.2 16-16V72c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v392c0 8.8 7.2 16 16 16h392c4.4 0 8 3.6 8 8v48c0 4.4-3.6 8-8 8H560c-8.8 0-16 7.2-16 16v392c0 4.4-3.6 8-8 8z',
                        })
                    )
                }

                getShape() {
                    const { model } = this.props
                    const { width, height, x, y, points } = model
                    const { fill, fillOpacity, strokeWidth, stroke, strokeOpacity } =
                        model.getNodeStyle()
                    const transform = `matrix(1 0 0 1 ${x - width / 2} ${y - height / 2})`
                    const pointsPath = points.map((point: any[]) => point.join(',')).join(' ')
                    return h('g', { transform }, [
                        h('polygon', {
                            points: pointsPath,
                            fill,
                            stroke,
                            strokeWidth,
                            strokeOpacity,
                            fillOpacity,
                        }),
                        this.getIconShape(),
                    ])
                }
            }
            class Model extends PolygonNodeModel {
                constructor(data: any, graphModel: any) {
                  // 重写自定义节点 id 的生成规则
                    if (!data.id) {
                        data.id = `Gateway_${ids.next()}`
                    }
                    data.text = {
                        value: (data.text && data.text.value) || '',
                        x: data.x,
                        y: data.y + 50,
                    }
                    super(data, graphModel)
                    const length = 25
                    this.points = [
                        [length, 0],
                        [length * 2, length],
                        [length, length * 2],
                        [0, length],
                    ]
                    
                }

                getNodeStyle() {
                    const style = super.getNodeStyle()
                    style.stroke = NODE_COLOR
                    return style
                }
            }
            return {
                view: Node,
                model: Model,
            }
        }
    )
}

2、基于图标的自定义的节点
(1)SVG

在这里插入图片描述


// eslint-disable-next-line max-classes-per-file
import Ids from 'ids'
// eslint-disable-next-line max-classes-per-file
export default function registerDataSave(lf: any) {
    const NODE_COLOR = '#187dff'
    const ids = new Ids([32, 32, 1])
    lf.register('bpmn:dataSave', ({ RectNode, RectNodeModel, h }) => {
        class View extends RectNode {
            getIconShape() {
                const { model } = this.props
                const { x, y, width, height } = model
                return [
                    h(
                        'svg',
                        {
                            x: x - width / 2,
                            y: y - height / 2,
                            width: 70,
                            height: 74,
                            viewBox: '200 0 1000 1200', // 走向 左↑ 右↓,上内边距,缩小,上内边距↑
                        },
                        h('path', {
                            fill: NODE_COLOR,
                            d: "M512 142.336c-80.896 0-161.792 7.168-224.256 20.48-31.744 7.168-59.392 16.384-80.896 27.648-20.48 10.24-36.864 24.576-41.984 44.032 0 1.024-1.024 3.072-1.024 4.096v486.4c5.12 21.504 22.528 35.84 43.008 47.104 21.504 11.264 49.152 20.48 80.896 26.624 62.464 14.336 143.36 20.48 224.256 20.48s161.792-6.144 224.256-20.48c31.744-6.144 59.392-15.36 80.896-26.624s37.888-25.6 43.008-47.104v-2.048-481.28-3.072c0-1.024 0-3.072-1.024-4.096-5.12-19.456-21.504-33.792-41.984-44.032-21.504-11.264-49.152-20.48-80.896-27.648-62.464-13.312-143.36-20.48-224.256-20.48z m0 35.84c78.848 0 157.696 7.168 217.088 20.48 29.696 6.144 54.272 14.336 70.656 22.528 13.312 7.168 20.48 14.336 23.552 19.456-3.072 5.12-10.24 12.288-23.552 19.456-16.384 9.216-40.96 17.408-70.656 23.552-59.392 12.288-138.24 19.456-217.088 19.456s-157.696-7.168-217.088-19.456c-29.696-6.144-54.272-14.336-70.656-23.552-13.312-7.168-20.48-14.336-23.552-19.456 3.072-5.12 10.24-12.288 23.552-19.456 16.384-8.192 40.96-16.384 70.656-22.528 59.392-13.312 138.24-20.48 217.088-20.48zM199.68 287.744c2.048 1.024 5.12 3.072 7.168 4.096 21.504 11.264 49.152 19.456 80.896 26.624 62.464 13.312 143.36 20.48 224.256 20.48s161.792-7.168 224.256-20.48c31.744-7.168 59.392-15.36 80.896-26.624 2.048-1.024 5.12-3.072 7.168-4.096v41.984c-2.048 5.12-8.192 13.312-24.576 21.504-16.384 9.216-40.96 17.408-70.656 23.552-59.392 12.288-138.24 19.456-217.088 19.456s-157.696-7.168-217.088-19.456c-29.696-6.144-54.272-14.336-70.656-23.552-15.36-8.192-22.528-16.384-24.576-21.504z m0 91.136c2.048 1.024 5.12 3.072 7.168 4.096 21.504 11.264 49.152 19.456 80.896 26.624 62.464 13.312 143.36 20.48 224.256 20.48s161.792-7.168 224.256-20.48c31.744-7.168 59.392-15.36 80.896-26.624 2.048-1.024 5.12-3.072 7.168-4.096v41.984c-2.048 5.12-8.192 13.312-24.576 21.504-16.384 9.216-40.96 17.408-70.656 23.552-59.392 12.288-138.24 19.456-217.088 19.456s-157.696-7.168-217.088-19.456c-29.696-6.144-54.272-14.336-70.656-23.552-15.36-8.192-22.528-16.384-24.576-21.504z m0 91.136c2.048 1.024 5.12 3.072 7.168 4.096 21.504 11.264 49.152 19.456 80.896 26.624 62.464 14.336 143.36 20.48 224.256 20.48s161.792-6.144 224.256-20.48c31.744-7.168 59.392-15.36 80.896-26.624 2.048-1.024 5.12-3.072 7.168-4.096v248.832c-2.048 5.12-8.192 13.312-24.576 21.504-16.384 9.216-40.96 17.408-70.656 23.552-59.392 13.312-138.24 19.456-217.088 19.456s-157.696-6.144-217.088-19.456c-29.696-6.144-54.272-14.336-70.656-23.552-15.36-8.192-22.528-16.384-24.576-21.504z",
                        })
                    ),
                ]
            }

            getShape() {
                const { model } = this.props
                const { x, y, width, height, radius } = model
                const style = model.getNodeStyle()
                return h('g', {}, [
                    h('rect', {
                        ...style,
                        x: x - width / 2,
                        y: y - height / 2,
                        strokeWidth: 0,
                        rx: radius,
                        ry: radius,
                        width,
                        height,
                    }),
                    ...this.getIconShape(),
                ])
            }
        }

        class Model extends RectNodeModel {
            constructor(data, graphModel) {
                if (!data.id) data.id = `DataObject_${ids.next()}`
                data.text = {
                    value: (data.text && data.text.value) || '',
                    x: data.x,
                    y: data.y + 50,
                }
                super(data, graphModel)
            }

            initNodeData(data) {
                super.initNodeData(data)
                this.width = 44
                this.height = 58
            }

            // 自定义锚点样式
            getAnchorStyle() {
                const style = super.getAnchorStyle()
                style.hover.r = 8
                style.hover.fill = 'rgb(24, 125, 255)'
                style.hover.stroke = 'rgb(24, 125, 255)'
                return style
            }

            getNodeStyle() {
                const style = super.getNodeStyle()
                style.stroke = NODE_COLOR
                return style
            }
        }

        return {
            view: View,
            model: Model,
        }
    })
}

github项目开源地址:传送🚪

在这里插入图片描述
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1084874.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

玩转Linux Shell Terminal Tmux

一、Shell编程☘️ 1. Shell指令快捷操作 1. echo # 系统指令 $ echo $(pwd) # 对于系统自带的pwd,此处不能写echo $pwd# 自定义变量 $ foo$(pwd) $ echo $foo # 不同于pwd,对于自定义的foo,不能用$(foo)2. !! # 假设你先执行了以下原本…

JOSEF约瑟 矿用一般型选择性漏电继电器 LXY2-660 Φ45 JKY1-660

系列型号: JY82A检漏继电器 JY82B检漏继电器 JY82-380/660检漏继电器 JY82-IV检漏继电器 JY82-2P检漏继电器 JY82-2/3检漏继电器 JJKY检漏继电器 JD型检漏继电器 JY82-IV;JY82J JY82-II;JY82-III JY82-1P;JY82-2PA;JY82-2PB JJB-380;JJB-380/660 JD-12…

Generics/泛型, ViewBuilder/视图构造器 的使用

1. Generics 泛型的定义及使用 1.1 创建使用泛型的实例 GenericsBootcamp.swift import SwiftUIstruct StringModel {let info: String?func removeInfo() -> StringModel{StringModel(info: nil)} }struct BoolModel {let info: Bool?func removeInfo() -> BoolModel…

解析Moonbeam的安全性、互操作性和市场竞争力

Moonbeam依托Polkadot Substrate框架构建,用Rust程序设计语言创建的智能合约区块链平台,在继承Polkadot安全性的基础上为项目提供以太坊虚拟机(EVM)的兼容性和原生的跨链互操作性优势。Moonbeam的EVM兼容性表示开发者无需学习Subs…

LeetCode-102-二叉树的层序遍历

题目描述: 给你二叉树的根节点 root ,返回其节点值的 层序遍历 。 (即逐层地,从左到右访问所有节点)。 题目链接:LeetCode-102-二叉树的层序遍历 解题思路: 使用队列 先进先出的特点存储每次遍…

spring 通过有参构造方法注入

1.先写一个有参构造方法 2.给构造方法里面的属性 name 赋值 lisi 3.测试

[ROS2系列] ubuntu 20.04测试rtabmap 3D建图(二)

接上文我们继续 如果我们要在仿真环境中进行测试&#xff0c;需要将摄像头配置成功。 一、配置位置 sudo vim /opt/ros/foxy/share/turtlebot3_gazebo/models/turtlebot3_waffle/model.sdf 二、修改 <joint name"camera_rgb_optical_joint" type"fixed&…

【数据库】Sql Server数据迁移,处理自增字段赋值

给自己一个目标&#xff0c;然后坚持一段时间&#xff0c;总会有收获和感悟&#xff01; 在实际项目开发中&#xff0c;如果遇到高版本导入到低版本&#xff0c;或者低版本转高版本&#xff0c;那么就会出现版本不兼容无法导入&#xff0c;此时通过程序遍历创建表和添加数据方式…

CRMEB多商户商城系统阿里云集群部署教程

注意: 1.所有服务创建时地域一定要选择一致,这里我用的是杭州K区 2.文件/图片上传一定要用类似oss的云文件服务, 本文不做演示 一、 创建容器镜像服务&#xff0c;容器镜像服务(aliyun.com) ,个人版本就可以 先创建一个命名空间 然后创建一个镜像仓库 查看并记录镜像公网地址…

Flink之窗口聚合算子

1.窗口聚合算子 在Flink中窗口聚合算子主要分类两类 滚动聚合算子(增量聚合)全窗口聚合算子(全量聚合) 1.1 滚动聚合算子 滚动聚合算子一次只处理一条数据,通过算子中的累加器对聚合结果进行更新,当窗口触发时再从累加器中取结果数据,一般使用算子如下: aggregatemaxmaxBy…

Unity中Shader光照模型Phong

文章目录 前言一、Phong光照模型二、图示解释Phone光照模型1、由图可得&#xff0c;R 可以由 -L 加上 P 得出2、P等于2*M3、因为 N 和 L 均为单位向量&#xff0c;所以 M 的模可以由 N 和 L得出4、得到M的模后&#xff0c;乘以 单位向量N&#xff0c;得到M5、最后得出 P 和 R 前…

Prometheus-Prometheus安装及其配置

Prometheus-Prometheus安装及其配置 Prometheus安装下载解压 配置启动prometheus校验配置文件表达式浏览器 Prometheus安装 Prometheus的安装针对Linux的安装&#xff0c;其他的安装方式可以查看Prometheus官网 下载 sudo wget https://github.com/prometheus/prometheus/re…

四款数字办公工具大比拼,在线办公无压力

在线办公软件使企业、员工实现办公场所、距离的自由&#xff0c;尤其是近几年&#xff0c;受“口罩”的影响&#xff0c;远程办公软件的使用者也越来越多&#xff0c;无论是财务、行政、还是设计师&#xff0c;都开始追求好用的在线办公软件&#xff0c;作为办公软件发烧友&…

发送消息时序图

内窥镜消息队列发送消息原理 目的 有一个多线程的Java应用程序&#xff0c;使用消息队列来处理命令 时序图 startumlactor User participant "sendCmdWhiteBalance()" as Controller participant CommandConsumer participant MessageQueueUser -> Controller:…

​左手 Serverless,右手 AI,7 年躬身的古籍修复之路

作者&#xff1a;宋杰 “AI 可以把我们思维体系当中&#xff0c;过度专业化、过度细分的这些所谓的知识都替代掉&#xff0c;让我们集中精力去体验自己的生命。我挺幸运的&#xff0c;代码能够有 AI 辅助&#xff0c;也能够有 Serverless 解决我的运营成本问题。Serverless 它…

mybatis拦截器源码分析

mybatis拦截器源码分析 拦截器简介 mybatis Plugins 拦截器由于Mybatis对数据库访问与操作进行了深度的封装,让我们应用开发效率大大提高,但是灵活度很差拦截器的作用:深度定制Mybatis的开发抛出一个需求 :获取Mybatis在开发过程中执行的SQL语句(执行什么操作获取那条SQL语句…

RK3562开发板:升级摄像头ISP,突破视觉体验边界

RK3562开发板作为深圳触觉智能新推出的爆款产品&#xff0c;采用 Rockchip 新一代 64 位处理器 RK3562&#xff08;Quad-core ARM Cortex-A53&#xff0c;主频最高 2.0GHz&#xff09;&#xff0c;最大支持 8GB 内存&#xff1b;内置独立的 NPU&#xff0c;可用于轻量级人工智能…

谷歌浏览查询http被自动转化成https导致页面读取失败问题处理

原因&#xff1a; 谷歌浏览器版本升级&#xff0c;安全问题考虑自动转化https 解决方案&#xff1a; 一、打开配置页面&#xff1a; chrome://flags/ 二、禁止自动转化

vue3_setup基础_渲染函数(ref,reactive)

一、setup语法糖 是什么&#xff1a;组合式Api &#xff08;vue2为option Api&#xff09; 来解决什么问题&#xff1a;使用&#xff08;data,computed,methonds,watch&#xff09;组件选项来组织逻辑通常都很有效。然而&#xff0c;当我们组件变的更大的时候&#xff0c;逻辑…

ansible的介绍安装与模块

目录 一、ansible简介 二、ansible特点 三、Ansible核心组件与工作原理 1、核心组件 2、工作原理 四、ansible的安装 五、ansible 命令行模块 1&#xff0e;command 模块 2&#xff0e;shell 模块 3&#xff0e;cron 模块 4&#xff0e;user 模块 5&#xff0e;group 模…