2 Star 3 Fork 1

craft-codeless-designer / typeorm-entity-designer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

TypeORM Entity Designer

An entity designer for typeorm, based on fabric.js.

@see http://fabricjs.com/ @see https://typeorm.io/#/separating-entity-definition

1. Intro

TypeORM Entity Designer 是一个用来在页面上绘制 ER 图的小工具,底层基于 fabricjs ,这个小工具可以自动生成 typeorm 规定的 Schema 格式,方便与 typeorm 进行对接。

内部只有 2 个核心类:Entity & Relation ,分别对应“实体”和“关系”。

只依赖以下 3 个 node 模块:

  • "fabric": "^4.4.0",
  • "pluralize": "^8.0.0",
  • "uuid": "^8.3.2"

其中 pluralize 和 uuid 已经被打包进去,fabric 需要使用 script 标签加载。(fabric 当前版本没有提供 ES 模块加载的方式。)

2. Usage


<!DOCTYPE html>
<html>
  <head>
    <title>Group</title>
    <script src="../node_modules/fabric/dist/fabric.js"></script>
    <script src="../dist/index.umd.js"></script>
  </head>
  <body>
    <div><canvas id="container" style="border: 1px solid #ccc" width="1024" height="768"></canvas></div>
    <script>
      let canvas = new fabric.Canvas('container', {
        preserveObjectStacking: true,
      });

      let boEntity1 = new fabric.BoEntity([], {
        width: 200,
        height: 100,
        fill: '#fee',
        stroke: '#000',
        padding: 5,
        linkable: true,
        title: 'testtesttesttesttesttesttesttesttesttesttest',
        fields: [
          {
            name: 'userName',
            type: 'String',
          },
          {
            name: 'userName',
            type: 'String',
          },
          {
            name: 'userName',
            type: 'String',
          },
          {
            name: 'userName',
            type: 'String',
          },
          {
            name: 'userName',
            type: 'String',
          },
          {
            name: 'userName',
            type: 'String',
          },
        ],
      });
      canvas.add(boEntity1);

      let link1 = new fabric.Link([500, 500, 300, 300], {
        stroke: '#f00',
        fill: '#f00',
        arrowType: 'both',
      });
      canvas.add(link1);

      link1.setLinkTo(boEntity1);

      let boEntity2 = new fabric.BoEntity([], {
        width: 200,
        height: 100,
        fill: '#fee',
        stroke: '#000',
        padding: 5,
        linkable: true,
        title: '2222',
        fields: [
          {
            name: 'userName',
            type: 'String',
          },
        ],
      });
      canvas.add(boEntity2);

      link1.setLinkFrom(boEntity2);

      console.log(canvas.toJSON());
      console.log(JSON.stringify(canvas));
    </script>
  </body>
</html>

注意:由于 fabric.js 是采用 ES5 语法编写的,没有支持 ES6 模块,ted 也采用了相同的技术栈来扩展功能,所以目前只能使用 <script> 标签的方式进行引入。

3. License

MIT licensed.

The MIT License (MIT) Copyright (c) 2021 大漠穷秋 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

图形化的实体设计器,与 typeorm 对接。 展开 收起
JavaScript 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/craft-codeless-designer/typeorm-entity-designer.git
git@gitee.com:craft-codeless-designer/typeorm-entity-designer.git
craft-codeless-designer
typeorm-entity-designer
typeorm-entity-designer
dev

搜索帮助