Giter Site home page Giter Site logo

lego's Introduction

可视化页面搭建

为什么要做这个东西,https://ltaoo.github.io/2018/02/09/%E5%8F%AF%E8%A7%86%E5%8C%96%E5%B8%83%E5%B1%80/

源对象

位于src/source/lib下的每个文件,都导出了一个对象,这个对象的结构如下:

enum SourceObj {
  // antd 组件
  Component,
  // 组件名
  label,
  // 在最终生成的代码 import { xx } from 'antd' 处使用
  import,
  // 在最终生成的代码 import 下方,正文上方使用
  extra,
  // 标志该组件是否为表单,影响编辑组件属性时的模态框
  notfield,
  // 出现在 constructor 函数内的代码
  constructorCode,
  // 就这个意思
  methods,
  // 会被添加到组件上的属性
  props,
}

最终生成的代码只从该对象得到,逻辑位于src/common/create-source.js

对象实例

在选择组件后,会生成一个新的对象,该对象仅仅在SourceObj上添加uuid属性,

enum SourceInstance {
  uuid,
  // ...
}

组件

|-------------|------------|
|                          |
|      App                 |
|                          |
| |---------||-----------| |
| |         ||           | |
| | Source  || Container | |
| |         ||           | |
| |---------||-----------| |
|                          |
|-----------|--------------|

最顶层的组件是AppSource提供对象实例,Container负责渲染组件并提供编辑功能。

Source

路径为src/components/Sources,点击生成对象实例,并传给App组件。

App

路径为src/App.js,掌控一切,在state中维护了一个instances数组,存放所有的对象实例。

Container

路径为src/components/Container,说这个是掌控一切或许更加合理,内部都是Field组件。

Field

路径为src/components/Field,该组件是实际看到的,不仅是antd组件本身,还有编辑按钮,编辑表单等,对组件的编辑都会反映到实例对象上。

最终生成的代码和该组件没有关系,代码只和实例对象有关。

lego's People

Contributors

ltaoo avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.