Vue + litegraph.js 实现蓝图功能

Vue3 + litegraph.js 实现蓝图功能

litegraph.js

	[github](https://github.com/jagenjo/litegraph.js)  
	[demo](https://tamats.com/projects/litegraph/editor/)

vue - html

    <canvas id="mycanvas" width="1524" height="720" style="border: 1px solid" ></canvas>

vue - ts

import {LGraph, LGraphCanvas, LiteGraph} from "litegraph.js";
import "litegraph.js/css/litegraph.css"

onMounted(()=>{
	initGraph();
})

const initGraph = ()=>{
	graph = new LGraph();
	var canvas = new LGraphCanvas('#mycanvas', graph)
}

//导入json文件
//graph.load(文件地址);

//导入json数据
graph.configure(json)

获取画布数据

graph.serialize()

json说明

{
        "last_node_id": 2, //必填,最后一个节点的id
        "last_link_id": 4, //必填,最后一根连线的id
        "nodes": [
            {
                "id": 2,
                "type": "event/explode",
                "pos": [
                    847,
                    479
                ],
                "size": {
                    "0": 200,
                    "1": 150
                },
                "flags": {
                    "horizontal": true
                },
                "order": 1,
                "mode": 2,
                "inputs": [
                    {
                        "name": "ABB结构",
                        "links": null,
                        "link": 4
                    }
                ],
                "outputs": [],
                "title": "事件-爆炸图",
                "properties": {}
            },
            {
                "id": 1,
                "type": "button",
                "pos": [
                    100,
                    100
                ],
                "size": {
                    "0": 130,
                    "1": 60
                },
                "flags": {
                    "horizontal": true
                },
                "order": 0,
                "mode": 0,
                "inputs": [],
                "outputs": [
                    {
                        "name": "点击",
                        "type": "number",
                        "links": [
                            2,
                            3,
                            4
                        ],
                        "slot_index": 0
                    },
                    {
                        "name": "双击",
                        "type": "number",
                        "links": null
                    }
                ],
                "title": "按钮",
                "properties": {}
            }
        ],
        "links": [
            [
                4, //连线id
                1, //origin_id 		源头节点id
                0, //origin_slot 	源头-出口序号
                2, //target-id 		目标节点id
                0, //target_slot 	目标-入口序号
                "number" //type
            ]
        ],
        "groups": [],
        "config": {},
        "extra": {},
        "version": 0.4
    }

相关推荐

  1. Vue + litegraph.js 实现蓝图功能

    2024-07-19 01:44:02       27 阅读
  2. 【Flask开发实战蓝图与子域名

    2024-07-19 01:44:02       25 阅读
  3. Python Flask实现蓝图Blueprint配置和模块渲染

    2024-07-19 01:44:02       22 阅读
  4. 制造行业数字化转型蓝图、转型路径及实施方案

    2024-07-19 01:44:02       37 阅读
  5. redis实现排行榜功能

    2024-07-19 01:44:02       65 阅读
  6. 支付功能实现

    2024-07-19 01:44:02       56 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-19 01:44:02       70 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-19 01:44:02       74 阅读
  3. 在Django里面运行非项目文件

    2024-07-19 01:44:02       62 阅读
  4. Python语言-面向对象

    2024-07-19 01:44:02       72 阅读

热门阅读

  1. c语言(函数7.18)

    2024-07-19 01:44:02       25 阅读
  2. RK3568 linux-5.10 rk809 声卡实现spk hp自动切换

    2024-07-19 01:44:02       22 阅读
  3. 蜣螂算法(BSO)及Python和MATLAB实现

    2024-07-19 01:44:02       23 阅读
  4. A. Little Nikita

    2024-07-19 01:44:02       21 阅读
  5. Ubuntu22,ROS2 colcon/cmake 编译卡死问题解决

    2024-07-19 01:44:02       21 阅读
  6. Mongodb文本索引

    2024-07-19 01:44:02       19 阅读
  7. ChatGPT:Stream 和 数据源

    2024-07-19 01:44:02       19 阅读
  8. 1.虚拟机相关的博文推荐

    2024-07-19 01:44:02       20 阅读
  9. Flink HA

    Flink HA

    2024-07-19 01:44:02      20 阅读
  10. vault正式环境安装部署

    2024-07-19 01:44:02       24 阅读
  11. 【Git】Git解除仓库关联或关联新仓库

    2024-07-19 01:44:02       19 阅读
  12. AIGC笔记--Classifer Guidance的代码理解

    2024-07-19 01:44:02       26 阅读
  13. rust 构建自己的库和模块

    2024-07-19 01:44:02       20 阅读
  14. 大语言模型系列-Transformer

    2024-07-19 01:44:02       25 阅读
  15. Git入门

    2024-07-19 01:44:02       25 阅读