项目作者: ghostiam

项目描述 :
Vue2 dataflow graph editor
高级语言: Vue
项目地址: git://github.com/ghostiam/vue-blocks.git
创建时间: 2018-02-05T06:29:54Z
项目社区:https://github.com/ghostiam/vue-blocks

开源协议:MIT License

下载


Vue-Blocks

Demo

Demo

Basic usage

  1. <template>
  2. <div id="app">
  3. <VueBlocksContainer
  4. ref="container"
  5. :blocksContent="blocks"
  6. :scene.sync="scene"
  7. class="container"></VueBlocksContainer>
  8. </div>
  9. </template>
  10. <script>
  11. import VueBlocksContainer from '...path.../vue-blocks/src'
  12. export default {
  13. name: 'App',
  14. components: {
  15. VueBlocksContainer
  16. },
  17. data: function () {
  18. return {
  19. blocks: [
  20. {
  21. name: 'test',
  22. title: 'Test block',
  23. family: 'Test',
  24. description: 'Description text',
  25. fields: [
  26. {
  27. name: 'in1',
  28. type: 'event',
  29. attr: 'input'
  30. },
  31. {
  32. name: 'in2',
  33. type: 'event',
  34. attr: 'input'
  35. },
  36. {
  37. name: 'out1',
  38. type: 'event',
  39. attr: 'output'
  40. },
  41. {
  42. name: 'out2',
  43. type: 'event',
  44. attr: 'output'
  45. }
  46. ]
  47. }
  48. ],
  49. scene: {
  50. blocks: [
  51. {
  52. id: 1,
  53. x: 0,
  54. y: 0,
  55. name: 'test',
  56. title: 'Test block',
  57. values: {
  58. property: [
  59. {
  60. name: 'message',
  61. type: 'string'
  62. }
  63. ]
  64. }
  65. },
  66. {
  67. id: 2,
  68. x: 0,
  69. y: 50,
  70. name: 'test',
  71. title: 'Test block 2',
  72. values: {
  73. property: [
  74. {
  75. name: 'message',
  76. type: 'string'
  77. }
  78. ]
  79. }
  80. }
  81. ],
  82. links: [],
  83. container: {
  84. centerX: 0,
  85. centerY: 0,
  86. scale: 1
  87. }
  88. }
  89. }
  90. }
  91. }
  92. </script>
  93. <style>
  94. html, body {
  95. margin: 0;
  96. padding: 0;
  97. }
  98. html {
  99. width: 100vw;
  100. height: 100vh;
  101. }
  102. body,
  103. #app,
  104. .container {
  105. width: 100%;
  106. height: 100%;
  107. }
  108. </style>

Props

blocksContent

Type: Array.<Node>

Required: true

Default: []

Object Node:

  1. {
  2. name: 'name-node',
  3. title: 'Title node',
  4. family: 'family - just for grouping',
  5. description: 'Description text',
  6. fields: Array.<NodeField>
  7. }

Object NodeField:

  1. {
  2. name: 'name',
  3. type: 'type-name', // not used
  4. attr: 'attribute' // input/output or custom
  5. 'other': - for custom
  6. }

Custom attributes are available in scene.blocks[index].values.YourAttrName

scene

Type: Object

Required: false

Default:

  1. {
  2. blocks: [],
  3. links: [],
  4. container: {}
  5. }

Object Scene:

  1. {
  2. blocks: Array.<Block>,
  3. links: Array.<BlockLinks>,
  4. container: {
  5. centerX: number
  6. centerY: number
  7. scale: number
  8. }
  9. }

Object Block:

  1. {
  2. id: number,
  3. x: number,
  4. y: number,
  5. name: string,
  6. title: string,
  7. values: {
  8. customAttribute: [ // show "NodeField"
  9. name: NodeField (without name and attr fields)
  10. ]
  11. }
  12. }

Object BlockLinks:

  1. {
  2. id: number, // ID
  3. originID: number, // Origin block ID
  4. originSlot: number, // Origin block slot number
  5. targetID: number, // Target block ID
  6. targetSlot: number // Target block slot number
  7. }

Build Setup

  1. # install dependencies
  2. npm install
  3. # serve with hot reload at localhost:8080
  4. npm run serve
  5. # build for production with minification
  6. npm run build
  7. # build for github pages
  8. npm run build:docs

License

MIT license