config.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import { v4 } from "uuid";
  2. import {ConditionMode, NodeDataStruct, NodePortStruct, NodeStruct, NodeType} from "@/views/workflow/types";
  3. import rootNodeDefault from "@/views/workflow/instance/root/default";
  4. import answerNodeDefault from "@/views/workflow/instance/answer/default";
  5. import ifElseNodeDefault from "@/views/workflow/instance/if-else/default";
  6. import testNodeDefault from "@/views/workflow/instance/test/default";
  7. export const lineStyle = {
  8. line: {
  9. stroke: '#8f8f8f',
  10. strokeWidth: 1,
  11. targetMarker: null
  12. },
  13. }
  14. export const portStyle = {
  15. attrs: {
  16. fo: {
  17. width: 12,
  18. height: 12,
  19. x: -9,
  20. y: -9,
  21. magnet: true,
  22. },
  23. },
  24. }
  25. export const nodeDefault = {
  26. [NodeType.Test]: () => (<NodeStruct>{
  27. x: 0,
  28. y: 0,
  29. data: <NodeDataStruct>{
  30. id: v4(),
  31. title: '测试节点',
  32. subTitle: '',
  33. ...testNodeDefault.defaultValue
  34. }
  35. }),
  36. [NodeType.Root]: () => (<NodeStruct>{
  37. x: 0,
  38. y: 0,
  39. data: <NodeDataStruct>{
  40. id: v4(),
  41. title: '开始',
  42. subTitle: '',
  43. ...rootNodeDefault.defaultValue,
  44. }
  45. }),
  46. [NodeType.Answer]: () => (<NodeStruct>{
  47. x: 0,
  48. y: 0,
  49. data: <NodeDataStruct>{
  50. id: v4(),
  51. title: '直接回复',
  52. subTitle: '',
  53. ...answerNodeDefault.defaultValue,
  54. }
  55. }),
  56. [NodeType.IfElse]: () => (<NodeStruct>{
  57. x: 0,
  58. y: 0,
  59. data: <NodeDataStruct>{
  60. id: v4(),
  61. title: '条件分支',
  62. subTitle: '',
  63. ...ifElseNodeDefault.defaultValue,
  64. ports: <NodePortStruct[]>[
  65. {
  66. id: v4(),
  67. ...ifElseNodeDefault.caseValue
  68. },
  69. {
  70. id: v4(),
  71. isElse: true
  72. },
  73. ],
  74. }
  75. }),
  76. }
  77. export const getNodeDefault = (type: NodeType) => {
  78. const node = nodeDefault[type]()
  79. node.id = node.data.id
  80. node.data.type = type
  81. return node
  82. }