aldehyde 0.2.487 → 0.2.489

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (717) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +2 -2
  3. package/lib/controls/2dEditor/2dEditor/index.less +5 -5
  4. package/lib/controls/2dEditor/2dView/index.less +8 -8
  5. package/lib/controls/2dEditor/components/component.less +83 -83
  6. package/lib/controls/action/index.css +8 -8
  7. package/lib/controls/action/index.d.ts.map +1 -1
  8. package/lib/controls/chemstruc/graph.d.ts.map +1 -1
  9. package/lib/controls/chemstruc/index.css +28 -28
  10. package/lib/controls/collapse-card/index.css +8 -8
  11. package/lib/controls/collapse-card/index.d.ts.map +1 -1
  12. package/lib/controls/cquery/cquick-button.d.ts.map +1 -1
  13. package/lib/controls/direct-file-view/index.d.ts.map +1 -1
  14. package/lib/controls/direct-file-view/index.js +2 -1
  15. package/lib/controls/direct-file-view/index.js.map +1 -1
  16. package/lib/controls/entity-select/entity-select.d.ts.map +1 -1
  17. package/lib/controls/entity-select/index.css +7 -7
  18. package/lib/controls/entity-select/lab-tree-select.d.ts.map +1 -1
  19. package/lib/controls/entity-select/popover-entity-select.d.ts.map +1 -1
  20. package/lib/controls/file-view/index.less +9 -9
  21. package/lib/controls/html-editor/index.less +67 -67
  22. package/lib/controls/icon-selector/icon/aldehyde-menu-icon/iconfont.css +147 -147
  23. package/lib/controls/password-setter/index.css +2 -2
  24. package/lib/controls/password-setter/index.d.ts.map +1 -1
  25. package/lib/controls/qr-code/index.less +28 -28
  26. package/lib/controls/relation-existion/index.css +3 -3
  27. package/lib/controls/relation-existion/index.d.ts.map +1 -1
  28. package/lib/controls/rfield/index.css +4 -4
  29. package/lib/controls/rfield/index.d.ts.map +1 -1
  30. package/lib/controls/select/index.d.ts.map +1 -1
  31. package/lib/controls/signature/index.d.ts.map +1 -1
  32. package/lib/controls/text/ellipsis-text.d.ts.map +1 -1
  33. package/lib/controls/text/index.less +7 -7
  34. package/lib/controls/upload/index.d.ts.map +1 -1
  35. package/lib/controls/upload/mult-file-upload.d.ts.map +1 -1
  36. package/lib/custom-page/dtmpl-custom-edit-modal-page.d.ts.map +1 -1
  37. package/lib/detail/button/bottom-submit-button-bar.d.ts.map +1 -1
  38. package/lib/detail/button/cquery-button-bar.d.ts.map +1 -1
  39. package/lib/detail/button/fix-right-submit-button-bar.d.ts.map +1 -1
  40. package/lib/detail/button/index.css +42 -42
  41. package/lib/detail/dtmpl.css +72 -72
  42. package/lib/detail/edit/fields-edit-card.d.ts.map +1 -1
  43. package/lib/detail/edit/modal-row-edit.d.ts.map +1 -1
  44. package/lib/detail/edit/popover-edit-card.d.ts.map +1 -1
  45. package/lib/detail/rightbar/index.css +34 -34
  46. package/lib/detail/rightbar/index.d.ts.map +1 -1
  47. package/lib/detail/view/act-dtmpl-view.d.ts.map +1 -1
  48. package/lib/detail/view/field-view-group.d.ts.map +1 -1
  49. package/lib/detail/view/modal-dtmpl-view.d.ts.map +1 -1
  50. package/lib/detail/view/snapshot-timeline.d.ts.map +1 -1
  51. package/lib/detail/view/tab-act-dtmpl-view.d.ts.map +1 -1
  52. package/lib/draw-canvas-edit/components/main-header/index.js +1 -1
  53. package/lib/draw-canvas-edit/components/render/components/index.less +60 -60
  54. package/lib/draw-canvas-edit/components/render/components/workstation-component.js +6 -6
  55. package/lib/draw-canvas-edit/components/render/draws/bg-draw.d.ts +1 -0
  56. package/lib/draw-canvas-edit/components/render/draws/bg-draw.d.ts.map +1 -1
  57. package/lib/draw-canvas-edit/components/render/draws/bg-draw.js +3 -2
  58. package/lib/draw-canvas-edit/components/render/draws/bg-draw.js.map +1 -1
  59. package/lib/draw-canvas-edit/components/render/draws/contextmenu-draw.d.ts +1 -0
  60. package/lib/draw-canvas-edit/components/render/draws/contextmenu-draw.d.ts.map +1 -1
  61. package/lib/draw-canvas-edit/components/render/draws/contextmenu-draw.js +2 -1
  62. package/lib/draw-canvas-edit/components/render/draws/contextmenu-draw.js.map +1 -1
  63. package/lib/draw-canvas-edit/components/render/draws/graph-draw.d.ts +1 -0
  64. package/lib/draw-canvas-edit/components/render/draws/graph-draw.d.ts.map +1 -1
  65. package/lib/draw-canvas-edit/components/render/draws/graph-draw.js +9 -8
  66. package/lib/draw-canvas-edit/components/render/draws/graph-draw.js.map +1 -1
  67. package/lib/draw-canvas-edit/components/render/draws/link-draw.d.ts +1 -0
  68. package/lib/draw-canvas-edit/components/render/draws/link-draw.d.ts.map +1 -1
  69. package/lib/draw-canvas-edit/components/render/draws/link-draw.js +24 -23
  70. package/lib/draw-canvas-edit/components/render/draws/link-draw.js.map +1 -1
  71. package/lib/draw-canvas-edit/components/render/draws/preview-draw.d.ts +1 -0
  72. package/lib/draw-canvas-edit/components/render/draws/preview-draw.d.ts.map +1 -1
  73. package/lib/draw-canvas-edit/components/render/draws/preview-draw.js +6 -5
  74. package/lib/draw-canvas-edit/components/render/draws/preview-draw.js.map +1 -1
  75. package/lib/draw-canvas-edit/components/render/draws/ref-line-draw.d.ts +1 -0
  76. package/lib/draw-canvas-edit/components/render/draws/ref-line-draw.d.ts.map +1 -1
  77. package/lib/draw-canvas-edit/components/render/draws/ref-line-draw.js +3 -2
  78. package/lib/draw-canvas-edit/components/render/draws/ref-line-draw.js.map +1 -1
  79. package/lib/draw-canvas-edit/components/render/draws/ruler-draw.d.ts +1 -0
  80. package/lib/draw-canvas-edit/components/render/draws/ruler-draw.d.ts.map +1 -1
  81. package/lib/draw-canvas-edit/components/render/draws/ruler-draw.js +8 -7
  82. package/lib/draw-canvas-edit/components/render/draws/ruler-draw.js.map +1 -1
  83. package/lib/draw-canvas-edit/components/render/graphs/base-graph.js +3 -3
  84. package/lib/draw-canvas-edit/components/render/graphs/bezier.js +5 -5
  85. package/lib/draw-canvas-edit/components/render/graphs/circle.js +4 -4
  86. package/lib/draw-canvas-edit/components/render/graphs/curve.js +5 -5
  87. package/lib/draw-canvas-edit/components/render/graphs/line.js +5 -5
  88. package/lib/draw-canvas-edit/components/render/graphs/rect.js +4 -4
  89. package/lib/draw-canvas-edit/components/render/handlers/drag-handlers.d.ts +1 -0
  90. package/lib/draw-canvas-edit/components/render/handlers/drag-handlers.d.ts.map +1 -1
  91. package/lib/draw-canvas-edit/components/render/handlers/drag-handlers.js +7 -6
  92. package/lib/draw-canvas-edit/components/render/handlers/drag-handlers.js.map +1 -1
  93. package/lib/draw-canvas-edit/components/render/handlers/drag-outside-handlers.d.ts +1 -0
  94. package/lib/draw-canvas-edit/components/render/handlers/drag-outside-handlers.d.ts.map +1 -1
  95. package/lib/draw-canvas-edit/components/render/handlers/drag-outside-handlers.js +4 -3
  96. package/lib/draw-canvas-edit/components/render/handlers/drag-outside-handlers.js.map +1 -1
  97. package/lib/draw-canvas-edit/components/render/handlers/graph-handlers.d.ts +1 -0
  98. package/lib/draw-canvas-edit/components/render/handlers/graph-handlers.d.ts.map +1 -1
  99. package/lib/draw-canvas-edit/components/render/handlers/graph-handlers.js +2 -1
  100. package/lib/draw-canvas-edit/components/render/handlers/graph-handlers.js.map +1 -1
  101. package/lib/draw-canvas-edit/components/render/handlers/key-move-handlers.d.ts +1 -0
  102. package/lib/draw-canvas-edit/components/render/handlers/key-move-handlers.d.ts.map +1 -1
  103. package/lib/draw-canvas-edit/components/render/handlers/key-move-handlers.js +5 -4
  104. package/lib/draw-canvas-edit/components/render/handlers/key-move-handlers.js.map +1 -1
  105. package/lib/draw-canvas-edit/components/render/handlers/link-handlers.d.ts +1 -0
  106. package/lib/draw-canvas-edit/components/render/handlers/link-handlers.d.ts.map +1 -1
  107. package/lib/draw-canvas-edit/components/render/handlers/link-handlers.js +3 -2
  108. package/lib/draw-canvas-edit/components/render/handlers/link-handlers.js.map +1 -1
  109. package/lib/draw-canvas-edit/components/render/handlers/selection-handlers.d.ts +1 -0
  110. package/lib/draw-canvas-edit/components/render/handlers/selection-handlers.d.ts.map +1 -1
  111. package/lib/draw-canvas-edit/components/render/handlers/selection-handlers.js +5 -4
  112. package/lib/draw-canvas-edit/components/render/handlers/selection-handlers.js.map +1 -1
  113. package/lib/draw-canvas-edit/components/render/handlers/shutcut-handlers.d.ts +1 -0
  114. package/lib/draw-canvas-edit/components/render/handlers/shutcut-handlers.d.ts.map +1 -1
  115. package/lib/draw-canvas-edit/components/render/handlers/shutcut-handlers.js +1 -0
  116. package/lib/draw-canvas-edit/components/render/handlers/shutcut-handlers.js.map +1 -1
  117. package/lib/draw-canvas-edit/components/render/handlers/text-handlers.d.ts +1 -0
  118. package/lib/draw-canvas-edit/components/render/handlers/text-handlers.d.ts.map +1 -1
  119. package/lib/draw-canvas-edit/components/render/handlers/text-handlers.js +1 -0
  120. package/lib/draw-canvas-edit/components/render/handlers/text-handlers.js.map +1 -1
  121. package/lib/draw-canvas-edit/components/render/handlers/zoom-handlers.d.ts +1 -0
  122. package/lib/draw-canvas-edit/components/render/handlers/zoom-handlers.d.ts.map +1 -1
  123. package/lib/draw-canvas-edit/components/render/handlers/zoom-handlers.js +7 -6
  124. package/lib/draw-canvas-edit/components/render/handlers/zoom-handlers.js.map +1 -1
  125. package/lib/draw-canvas-edit/components/render/index.js +48 -48
  126. package/lib/draw-canvas-edit/components/render/tools/align-tool.js +4 -4
  127. package/lib/draw-canvas-edit/components/render/tools/asset-tool.js +1 -1
  128. package/lib/draw-canvas-edit/components/render/tools/copy-tool.js +4 -4
  129. package/lib/draw-canvas-edit/components/render/tools/import-export-tool.js +7 -7
  130. package/lib/draw-canvas-edit/components/render/tools/link-tool.js +9 -9
  131. package/lib/draw-canvas-edit/components/render/tools/position-tool.js +18 -18
  132. package/lib/draw-canvas-edit/components/render/tools/selection-tool.js +2 -2
  133. package/lib/draw-canvas-edit/components/render/tools/z-index-tool.js +16 -16
  134. package/lib/draw-canvas-edit/index.less +48 -48
  135. package/lib/draw-canvas-view/index.less +66 -66
  136. package/lib/export/export-frame.css +2 -2
  137. package/lib/export/export-frame.d.ts.map +1 -1
  138. package/lib/export/select-code-export-frame.d.ts.map +1 -1
  139. package/lib/form/dtmpl-form.css +3 -3
  140. package/lib/form/dtmpl-form.d.ts.map +1 -1
  141. package/lib/form/field-group-form.d.ts.map +1 -1
  142. package/lib/form/form-Item-group.d.ts.map +1 -1
  143. package/lib/form/index.css +12 -12
  144. package/lib/import/excel-import.d.ts.map +1 -1
  145. package/lib/import/index.css +53 -53
  146. package/lib/import/template.css +50 -50
  147. package/lib/layout/common.css +64 -64
  148. package/lib/layout/coverstyle.css +51 -51
  149. package/lib/layout/footer/index.css +5 -5
  150. package/lib/layout/header/index.css +122 -122
  151. package/lib/layout/menu/block.css +7 -7
  152. package/lib/layout/menu/block.d.ts.map +1 -1
  153. package/lib/layout/menu/l2menu-quick-bar.d.ts.map +1 -1
  154. package/lib/layout/menu/menu-2layers.d.ts.map +1 -1
  155. package/lib/layout/menu/message-bar.less +73 -73
  156. package/lib/layout/menu/reset-password.d.ts.map +1 -1
  157. package/lib/layout/menu/user-bar.d.ts.map +1 -1
  158. package/lib/layout/menu/userinfo-bar.d.ts.map +1 -1
  159. package/lib/layout/sidebar/index.css +57 -57
  160. package/lib/layout2/css/header.css +41 -41
  161. package/lib/layout2/css/sider.less +17 -17
  162. package/lib/layout2/css/tabs-layout.less +18 -18
  163. package/lib/layout3/css/header.less +195 -195
  164. package/lib/layout3/css/main.less +161 -161
  165. package/lib/layout3/css/sider.less +32 -32
  166. package/lib/layout3/css/tabs-layout.less +38 -38
  167. package/lib/layout4/css/header.less +196 -196
  168. package/lib/layout4/css/main.less +154 -154
  169. package/lib/layout4/css/sider.less +37 -37
  170. package/lib/layout4/css/tabs-layout.less +42 -42
  171. package/lib/layout5/css/header.less +35 -35
  172. package/lib/layout5/css/sider.less +18 -18
  173. package/lib/list/calendar/index.less +20 -20
  174. package/lib/list/card-list/index.less +154 -154
  175. package/lib/list/gantt/index.less +8 -8
  176. package/lib/list/vertical-list/index.less +208 -208
  177. package/lib/login/index.css +19 -19
  178. package/lib/login/login.d.ts.map +1 -1
  179. package/lib/login/vertify/index.css +143 -143
  180. package/lib/login3/index.less +136 -136
  181. package/lib/lowcode-components/act-table/index.less +26 -26
  182. package/lib/lowcode-components/bar-chart/index.d.ts +4 -1
  183. package/lib/lowcode-components/bar-chart/index.d.ts.map +1 -1
  184. package/lib/lowcode-components/bar-chart/index.js +3 -0
  185. package/lib/lowcode-components/bar-chart/index.js.map +1 -1
  186. package/lib/lowcode-components/base-button/index.less +7 -7
  187. package/lib/lowcode-components/base-map/index.js +6 -6
  188. package/lib/lowcode-components/base-radio/index.less +23 -23
  189. package/lib/lowcode-components/base-tabs/index.less +14 -14
  190. package/lib/lowcode-components/border/border10/index.less +26 -26
  191. package/lib/lowcode-components/border/border11/index.js +46 -46
  192. package/lib/lowcode-components/border/border11/index.less +17 -17
  193. package/lib/lowcode-components/border/border12/index.js +13 -13
  194. package/lib/lowcode-components/border/border12/index.less +13 -13
  195. package/lib/lowcode-components/border/border13/index.js +5 -5
  196. package/lib/lowcode-components/border/border13/index.less +13 -13
  197. package/lib/lowcode-components/border/border2/index.less +17 -17
  198. package/lib/lowcode-components/border/border3/index.less +25 -25
  199. package/lib/lowcode-components/border/border4/index.js +2 -2
  200. package/lib/lowcode-components/border/border4/index.less +72 -72
  201. package/lib/lowcode-components/border/border5/index.js +2 -2
  202. package/lib/lowcode-components/border/border5/index.less +35 -35
  203. package/lib/lowcode-components/border/border6/index.less +17 -17
  204. package/lib/lowcode-components/border/border7/index.less +26 -26
  205. package/lib/lowcode-components/border/border8/index.less +13 -13
  206. package/lib/lowcode-components/border/border9/index.js +14 -14
  207. package/lib/lowcode-components/border/border9/index.less +13 -13
  208. package/lib/lowcode-components/column-3d-chart/index.d.ts +4 -1
  209. package/lib/lowcode-components/column-3d-chart/index.d.ts.map +1 -1
  210. package/lib/lowcode-components/column-3d-chart/index.js +3 -0
  211. package/lib/lowcode-components/column-3d-chart/index.js.map +1 -1
  212. package/lib/lowcode-components/column-chart/index.d.ts +6 -3
  213. package/lib/lowcode-components/column-chart/index.d.ts.map +1 -1
  214. package/lib/lowcode-components/column-chart/index.js +4 -1
  215. package/lib/lowcode-components/column-chart/index.js.map +1 -1
  216. package/lib/lowcode-components/decoration/decoration1/index.less +7 -7
  217. package/lib/lowcode-components/decoration/decoration10/index.js +3 -3
  218. package/lib/lowcode-components/decoration/decoration10/index.less +5 -5
  219. package/lib/lowcode-components/decoration/decoration11/index.less +5 -5
  220. package/lib/lowcode-components/decoration/decoration2/index.less +6 -6
  221. package/lib/lowcode-components/decoration/decoration3/index.less +7 -7
  222. package/lib/lowcode-components/decoration/decoration4/index.less +29 -29
  223. package/lib/lowcode-components/decoration/decoration5/index.less +3 -3
  224. package/lib/lowcode-components/decoration/decoration6/index.less +7 -7
  225. package/lib/lowcode-components/decoration/decoration7/index.less +4 -4
  226. package/lib/lowcode-components/decoration/decoration8/index.less +14 -14
  227. package/lib/lowcode-components/decoration/decoration9/index.less +4 -4
  228. package/lib/lowcode-components/effectScatter-map/index.js +6 -6
  229. package/lib/lowcode-components/effectScatter-map-3d/index.js +6 -6
  230. package/lib/lowcode-components/line-bar-chart/index.d.ts +4 -1
  231. package/lib/lowcode-components/line-bar-chart/index.d.ts.map +1 -1
  232. package/lib/lowcode-components/line-bar-chart/index.js +3 -0
  233. package/lib/lowcode-components/line-bar-chart/index.js.map +1 -1
  234. package/lib/lowcode-components/line-chart/index.d.ts +5 -2
  235. package/lib/lowcode-components/line-chart/index.d.ts.map +1 -1
  236. package/lib/lowcode-components/line-chart/index.js +6 -2
  237. package/lib/lowcode-components/line-chart/index.js.map +1 -1
  238. package/lib/lowcode-components/lowcode-view/index.less +19 -19
  239. package/lib/lowcode-components/pie-chart/index.d.ts +4 -1
  240. package/lib/lowcode-components/pie-chart/index.d.ts.map +1 -1
  241. package/lib/lowcode-components/pie-chart/index.js +3 -0
  242. package/lib/lowcode-components/pie-chart/index.js.map +1 -1
  243. package/lib/lowcode-components/search-form/index.less +25 -25
  244. package/lib/module/dtmpl-edit-card.d.ts.map +1 -1
  245. package/lib/module/dtmpl-edit-card.js +15 -5
  246. package/lib/module/dtmpl-edit-card.js.map +1 -1
  247. package/lib/module/dtmpl-edit-page.d.ts.map +1 -1
  248. package/lib/module/dtmpl-edit-page.js +15 -5
  249. package/lib/module/dtmpl-edit-page.js.map +1 -1
  250. package/lib/module/index.less +4 -4
  251. package/lib/module/ltmpl-modal.d.ts.map +1 -1
  252. package/lib/module/ltmpl-table.d.ts.map +1 -1
  253. package/lib/routable/index.less +25 -25
  254. package/lib/table/act-table.d.ts +2 -0
  255. package/lib/table/act-table.d.ts.map +1 -1
  256. package/lib/table/act-table.js +20 -17
  257. package/lib/table/act-table.js.map +1 -1
  258. package/lib/table/column/index.less +85 -85
  259. package/lib/table/index.css +211 -211
  260. package/lib/table/modal-select-table.d.ts.map +1 -1
  261. package/lib/table/page-chart.d.ts +15 -0
  262. package/lib/table/page-chart.d.ts.map +1 -0
  263. package/lib/table/page-chart.js +150 -0
  264. package/lib/table/page-chart.js.map +1 -0
  265. package/lib/table/page-chart.less +10 -0
  266. package/lib/table/pagination.css +14 -14
  267. package/lib/table/pagination.d.ts.map +1 -1
  268. package/lib/table/relation-table.d.ts +2 -0
  269. package/lib/table/relation-table.d.ts.map +1 -1
  270. package/lib/table/row-table.d.ts +11 -0
  271. package/lib/table/row-table.d.ts.map +1 -0
  272. package/lib/table/row-table.js +11 -0
  273. package/lib/table/row-table.js.map +1 -0
  274. package/lib/table/selected-rows-card.d.ts.map +1 -1
  275. package/lib/table/stat/restat.d.ts.map +1 -1
  276. package/lib/tmpl/interface.d.ts +12 -1
  277. package/lib/tmpl/interface.d.ts.map +1 -1
  278. package/lib/tmpl/interface.js.map +1 -1
  279. package/lib/tmpl/tmpl-config-analysis.js +1 -1
  280. package/lib/tmpl/tmpl-config-analysis.js.map +1 -1
  281. package/lib/tree/act-tree.d.ts.map +1 -1
  282. package/lib/tree/block-menu-auth-tree.d.ts.map +1 -1
  283. package/lib/tree/index.css +22 -22
  284. package/lib/tree/tmpl-tree.d.ts.map +1 -1
  285. package/lib/welcome/components/menu-card.less +96 -96
  286. package/lib/welcome/components/page-card.less +49 -49
  287. package/lib/welcome/components/quick-entrance.less +120 -120
  288. package/lib/welcome/components/user-menus.less +192 -192
  289. package/lib/welcome/components/workbench.less +118 -118
  290. package/lib/welcome/index.css +13 -13
  291. package/package.json +224 -224
  292. package/src/aldehyde/controls/2dEditor/2dEditor/index.less +5 -5
  293. package/src/aldehyde/controls/2dEditor/2dEditor/index.tsx +270 -270
  294. package/src/aldehyde/controls/2dEditor/2dView/index.less +8 -8
  295. package/src/aldehyde/controls/2dEditor/2dView/index.tsx +110 -110
  296. package/src/aldehyde/controls/2dEditor/components/card.tsx +256 -256
  297. package/src/aldehyde/controls/2dEditor/components/component.less +83 -83
  298. package/src/aldehyde/controls/2dEditor/components/data.d.ts +32 -32
  299. package/src/aldehyde/controls/2dEditor/components/hotspot.tsx +80 -80
  300. package/src/aldehyde/controls/2dEditor/components/html-box.tsx +101 -101
  301. package/src/aldehyde/controls/2dEditor/components/image.tsx +99 -99
  302. package/src/aldehyde/controls/2dEditor/components/line.tsx +73 -73
  303. package/src/aldehyde/controls/action/index.css +8 -8
  304. package/src/aldehyde/controls/action/index.tsx +406 -406
  305. package/src/aldehyde/controls/action/utils.tsx +306 -306
  306. package/src/aldehyde/controls/auto-complete/index.tsx +82 -82
  307. package/src/aldehyde/controls/cascader/index.tsx +112 -112
  308. package/src/aldehyde/controls/chemstruc/graph.tsx +185 -185
  309. package/src/aldehyde/controls/chemstruc/index.css +28 -28
  310. package/src/aldehyde/controls/code-editor/sql-code-editor.tsx +73 -73
  311. package/src/aldehyde/controls/collapse-card/index.css +8 -8
  312. package/src/aldehyde/controls/collapse-card/index.tsx +109 -109
  313. package/src/aldehyde/controls/color-picker/index.tsx +21 -21
  314. package/src/aldehyde/controls/counting-tag/index.tsx +53 -53
  315. package/src/aldehyde/controls/cquery/cquick-button.tsx +145 -145
  316. package/src/aldehyde/controls/date-picker/index.tsx +199 -199
  317. package/src/aldehyde/controls/direct-file-view/drawer-file-view.tsx +54 -54
  318. package/src/aldehyde/controls/direct-file-view/index.tsx +147 -146
  319. package/src/aldehyde/controls/direct-upload/index.tsx +140 -140
  320. package/src/aldehyde/controls/entity-select/entity-select.tsx +791 -791
  321. package/src/aldehyde/controls/entity-select/index.css +7 -7
  322. package/src/aldehyde/controls/entity-select/lab-tree-select.tsx +154 -154
  323. package/src/aldehyde/controls/entity-select/popover-entity-select.tsx +205 -205
  324. package/src/aldehyde/controls/entry-control.tsx +431 -431
  325. package/src/aldehyde/controls/enum-badge/index.tsx +42 -42
  326. package/src/aldehyde/controls/enum-tag/index.tsx +45 -45
  327. package/src/aldehyde/controls/field-history/index.tsx +81 -81
  328. package/src/aldehyde/controls/file-export/select-code-export.tsx +40 -40
  329. package/src/aldehyde/controls/file-view/drawer-file-view.tsx +117 -117
  330. package/src/aldehyde/controls/file-view/index.less +9 -9
  331. package/src/aldehyde/controls/file-view/index.tsx +148 -148
  332. package/src/aldehyde/controls/file-view/multi-file-view.tsx +39 -39
  333. package/src/aldehyde/controls/file-view/newin-file-view.tsx +40 -40
  334. package/src/aldehyde/controls/html-editor/draft.tsx +136 -136
  335. package/src/aldehyde/controls/html-editor/index.less +67 -67
  336. package/src/aldehyde/controls/icon-selector/app-icon-selector.tsx +68 -68
  337. package/src/aldehyde/controls/icon-selector/icon/aldehyde-menu-icon/iconfont.css +147 -147
  338. package/src/aldehyde/controls/icon-selector/icon/aldehyde-menu-icon/iconfont.json +240 -240
  339. package/src/aldehyde/controls/icon-selector/pc-icon-selector.tsx +68 -68
  340. package/src/aldehyde/controls/input-number/index.tsx +148 -148
  341. package/src/aldehyde/controls/input-range/index.tsx +59 -59
  342. package/src/aldehyde/controls/password-setter/index.css +2 -2
  343. package/src/aldehyde/controls/password-setter/index.js +88 -88
  344. package/src/aldehyde/controls/progress/index.tsx +74 -74
  345. package/src/aldehyde/controls/qr-code/index.less +28 -28
  346. package/src/aldehyde/controls/qr-code/index.tsx +40 -40
  347. package/src/aldehyde/controls/relation-existion/index.css +3 -3
  348. package/src/aldehyde/controls/relation-existion/index.tsx +144 -144
  349. package/src/aldehyde/controls/rfield/index.css +4 -4
  350. package/src/aldehyde/controls/rfield/index.tsx +225 -225
  351. package/src/aldehyde/controls/select/index.tsx +226 -226
  352. package/src/aldehyde/controls/signature/index.tsx +226 -226
  353. package/src/aldehyde/controls/single-checkbox/index.tsx +18 -18
  354. package/src/aldehyde/controls/steps/index.tsx +59 -59
  355. package/src/aldehyde/controls/text/ellipsis-text.tsx +98 -98
  356. package/src/aldehyde/controls/text/index.less +7 -7
  357. package/src/aldehyde/controls/tree-select/navigation-tree.tsx +122 -122
  358. package/src/aldehyde/controls/tree-select/tree-entity-select.tsx +121 -121
  359. package/src/aldehyde/controls/upload/index.tsx +128 -128
  360. package/src/aldehyde/controls/upload/mult-file-upload.tsx +240 -240
  361. package/src/aldehyde/controls/upload-read-excel/index.tsx +43 -43
  362. package/src/aldehyde/controls/view-control.tsx +289 -289
  363. package/src/aldehyde/custom-page/custom-detail-modal-page.tsx +69 -69
  364. package/src/aldehyde/custom-page/custom-page-router.tsx +64 -64
  365. package/src/aldehyde/custom-page/def-custom-page.tsx +17 -17
  366. package/src/aldehyde/custom-page/dtmpl-custom-edit-modal-page.tsx +88 -88
  367. package/src/aldehyde/detail/button/bottom-submit-button-bar.tsx +91 -91
  368. package/src/aldehyde/detail/button/cquery-button-bar.tsx +144 -144
  369. package/src/aldehyde/detail/button/edit-button.tsx +61 -61
  370. package/src/aldehyde/detail/button/fix-right-submit-button-bar.tsx +186 -186
  371. package/src/aldehyde/detail/button/index.css +42 -42
  372. package/src/aldehyde/detail/button/inline-edit-button.tsx +40 -40
  373. package/src/aldehyde/detail/button/submit-button-bar.tsx +57 -57
  374. package/src/aldehyde/detail/button/view-button.tsx +64 -64
  375. package/src/aldehyde/detail/dtmpl.css +72 -72
  376. package/src/aldehyde/detail/edit/dtmpl-edit.tsx +279 -279
  377. package/src/aldehyde/detail/edit/fields-edit-card.tsx +145 -145
  378. package/src/aldehyde/detail/edit/modal-row-edit.tsx +95 -95
  379. package/src/aldehyde/detail/edit/popover-edit-card.tsx +167 -167
  380. package/src/aldehyde/detail/edit/popover-editor.tsx +70 -70
  381. package/src/aldehyde/detail/edit/post-result/index.tsx +86 -86
  382. package/src/aldehyde/detail/rightbar/index.css +34 -34
  383. package/src/aldehyde/detail/rightbar/index.tsx +92 -92
  384. package/src/aldehyde/detail/tooltipbar/index.tsx +32 -32
  385. package/src/aldehyde/detail/view/act-dtmpl-view.tsx +288 -288
  386. package/src/aldehyde/detail/view/dtmpl-view.tsx +334 -334
  387. package/src/aldehyde/detail/view/field-view-group.tsx +88 -88
  388. package/src/aldehyde/detail/view/modal-dtmpl-view.tsx +73 -73
  389. package/src/aldehyde/detail/view/snapshot-timeline.tsx +231 -231
  390. package/src/aldehyde/detail/view/tab-act-dtmpl-view.tsx +304 -304
  391. package/src/aldehyde/detail/view/view-compare-panel.tsx +57 -57
  392. package/src/aldehyde/draw-canvas-edit/components/main-header/index.tsx +1 -1
  393. package/src/aldehyde/draw-canvas-edit/components/render/components/index.less +60 -60
  394. package/src/aldehyde/draw-canvas-edit/components/render/components/index.ts +3 -3
  395. package/src/aldehyde/draw-canvas-edit/components/render/components/workstation-component.tsx +220 -220
  396. package/src/aldehyde/draw-canvas-edit/components/render/draws/bg-draw.ts +177 -176
  397. package/src/aldehyde/draw-canvas-edit/components/render/draws/contextmenu-draw.ts +330 -329
  398. package/src/aldehyde/draw-canvas-edit/components/render/draws/graph-draw.ts +249 -249
  399. package/src/aldehyde/draw-canvas-edit/components/render/draws/link-draw.ts +1415 -1414
  400. package/src/aldehyde/draw-canvas-edit/components/render/draws/preview-draw.ts +274 -273
  401. package/src/aldehyde/draw-canvas-edit/components/render/draws/ref-line-draw.ts +71 -70
  402. package/src/aldehyde/draw-canvas-edit/components/render/draws/ruler-draw.ts +166 -165
  403. package/src/aldehyde/draw-canvas-edit/components/render/graphs/base-graph.ts +3 -3
  404. package/src/aldehyde/draw-canvas-edit/components/render/graphs/bezier.ts +542 -542
  405. package/src/aldehyde/draw-canvas-edit/components/render/graphs/circle.ts +4 -4
  406. package/src/aldehyde/draw-canvas-edit/components/render/graphs/curve.ts +5 -5
  407. package/src/aldehyde/draw-canvas-edit/components/render/graphs/line.ts +5 -5
  408. package/src/aldehyde/draw-canvas-edit/components/render/graphs/rect.ts +4 -4
  409. package/src/aldehyde/draw-canvas-edit/components/render/handlers/drag-handlers.ts +7 -6
  410. package/src/aldehyde/draw-canvas-edit/components/render/handlers/drag-outside-handlers.ts +77 -76
  411. package/src/aldehyde/draw-canvas-edit/components/render/handlers/graph-handlers.ts +2 -1
  412. package/src/aldehyde/draw-canvas-edit/components/render/handlers/key-move-handlers.ts +5 -4
  413. package/src/aldehyde/draw-canvas-edit/components/render/handlers/link-handlers.ts +3 -2
  414. package/src/aldehyde/draw-canvas-edit/components/render/handlers/selection-handlers.ts +410 -409
  415. package/src/aldehyde/draw-canvas-edit/components/render/handlers/shutcut-handlers.ts +1 -0
  416. package/src/aldehyde/draw-canvas-edit/components/render/handlers/text-handlers.ts +1 -0
  417. package/src/aldehyde/draw-canvas-edit/components/render/handlers/zoom-handlers.ts +7 -6
  418. package/src/aldehyde/draw-canvas-edit/components/render/index.ts +817 -817
  419. package/src/aldehyde/draw-canvas-edit/components/render/tools/align-tool.ts +4 -4
  420. package/src/aldehyde/draw-canvas-edit/components/render/tools/asset-tool.ts +1 -1
  421. package/src/aldehyde/draw-canvas-edit/components/render/tools/attract-tool.ts +457 -457
  422. package/src/aldehyde/draw-canvas-edit/components/render/tools/component-factory.ts +269 -269
  423. package/src/aldehyde/draw-canvas-edit/components/render/tools/copy-tool.ts +244 -244
  424. package/src/aldehyde/draw-canvas-edit/components/render/tools/import-export-tool.ts +588 -588
  425. package/src/aldehyde/draw-canvas-edit/components/render/tools/index.ts +10 -10
  426. package/src/aldehyde/draw-canvas-edit/components/render/tools/link-tool.ts +9 -9
  427. package/src/aldehyde/draw-canvas-edit/components/render/tools/position-tool.ts +191 -191
  428. package/src/aldehyde/draw-canvas-edit/components/render/tools/selection-tool.ts +140 -140
  429. package/src/aldehyde/draw-canvas-edit/components/render/tools/z-index-tool.ts +16 -16
  430. package/src/aldehyde/draw-canvas-edit/components/render/types.ts +298 -298
  431. package/src/aldehyde/draw-canvas-edit/components/setting-form/index.tsx +305 -305
  432. package/src/aldehyde/draw-canvas-edit/constant.ts +5 -5
  433. package/src/aldehyde/draw-canvas-edit/index.less +48 -48
  434. package/src/aldehyde/draw-canvas-edit/index.tsx +213 -213
  435. package/src/aldehyde/draw-canvas-view/index.less +66 -66
  436. package/src/aldehyde/draw-canvas-view/index.tsx +49 -49
  437. package/src/aldehyde/draw-canvas-view/view.tsx +237 -237
  438. package/src/aldehyde/export/export-frame.css +2 -2
  439. package/src/aldehyde/export/export-frame.tsx +301 -301
  440. package/src/aldehyde/export/select-code-export-frame.tsx +212 -212
  441. package/src/aldehyde/form/criteria-form.tsx +604 -604
  442. package/src/aldehyde/form/dtmpl-form.css +3 -3
  443. package/src/aldehyde/form/dtmpl-form.tsx +571 -571
  444. package/src/aldehyde/form/field-group-form.tsx +103 -103
  445. package/src/aldehyde/form/fields-form.tsx +45 -45
  446. package/src/aldehyde/form/form-Item-group.tsx +246 -246
  447. package/src/aldehyde/form/index.css +12 -12
  448. package/src/aldehyde/hooks/use-match-route/index.tsx +62 -62
  449. package/src/aldehyde/hooks/use-tabs/index.tsx +139 -139
  450. package/src/aldehyde/hooks/useVarCssColor.ts +6 -6
  451. package/src/aldehyde/icon/aliIcon.tsx +9 -9
  452. package/src/aldehyde/icon/index.tsx +28 -28
  453. package/src/aldehyde/import/excel-import.tsx +450 -450
  454. package/src/aldehyde/import/index.css +53 -53
  455. package/src/aldehyde/import/template.css +50 -50
  456. package/src/aldehyde/index.tsx +220 -220
  457. package/src/aldehyde/layout/MainPage.tsx +334 -334
  458. package/src/aldehyde/layout/common.css +64 -64
  459. package/src/aldehyde/layout/coverstyle.css +51 -51
  460. package/src/aldehyde/layout/footer/index.css +5 -5
  461. package/src/aldehyde/layout/footer/index.js +17 -17
  462. package/src/aldehyde/layout/header/index.css +122 -122
  463. package/src/aldehyde/layout/header/index.tsx +152 -152
  464. package/src/aldehyde/layout/menu/block.css +7 -7
  465. package/src/aldehyde/layout/menu/block.tsx +174 -174
  466. package/src/aldehyde/layout/menu/l2menu-message-bar.tsx +160 -160
  467. package/src/aldehyde/layout/menu/l2menu-quick-bar.tsx +175 -175
  468. package/src/aldehyde/layout/menu/menu-2layers.tsx +117 -117
  469. package/src/aldehyde/layout/menu/menu-render.tsx +168 -168
  470. package/src/aldehyde/layout/menu/message-bar.less +73 -73
  471. package/src/aldehyde/layout/menu/reset-password.tsx +255 -255
  472. package/src/aldehyde/layout/menu/user-bar.tsx +259 -259
  473. package/src/aldehyde/layout/menu/userinfo-bar.tsx +69 -69
  474. package/src/aldehyde/layout/sidebar/index.css +57 -57
  475. package/src/aldehyde/layout/sidebar/index.tsx +84 -84
  476. package/src/aldehyde/layout2/components/icon-font.tsx +7 -7
  477. package/src/aldehyde/layout2/components/screenfull-button.tsx +21 -21
  478. package/src/aldehyde/layout2/components/search-menu.tsx +85 -85
  479. package/src/aldehyde/layout2/components/system-messages.tsx +75 -75
  480. package/src/aldehyde/layout2/components/theme-button.tsx +65 -65
  481. package/src/aldehyde/layout2/components/user-button.tsx +258 -258
  482. package/src/aldehyde/layout2/components/user-notification.tsx +74 -74
  483. package/src/aldehyde/layout2/css/header.css +41 -41
  484. package/src/aldehyde/layout2/css/sider.less +17 -17
  485. package/src/aldehyde/layout2/css/tabs-layout.less +18 -18
  486. package/src/aldehyde/layout2/header.tsx +278 -278
  487. package/src/aldehyde/layout2/layout-context.tsx +95 -95
  488. package/src/aldehyde/layout2/main.tsx +30 -30
  489. package/src/aldehyde/layout2/page.tsx +315 -315
  490. package/src/aldehyde/layout2/sider.tsx +230 -230
  491. package/src/aldehyde/layout2/tabs/tabs-context.tsx +37 -37
  492. package/src/aldehyde/layout2/tabs/tabs-layout.tsx +146 -146
  493. package/src/aldehyde/layout2/type/layout-type.ts +15 -15
  494. package/src/aldehyde/layout2/util/menu-util.tsx +125 -125
  495. package/src/aldehyde/layout3/components/tabs-layout.tsx +110 -110
  496. package/src/aldehyde/layout3/components/time.tsx +25 -25
  497. package/src/aldehyde/layout3/css/header.less +195 -195
  498. package/src/aldehyde/layout3/css/main.less +161 -161
  499. package/src/aldehyde/layout3/css/sider.less +32 -32
  500. package/src/aldehyde/layout3/css/tabs-layout.less +38 -38
  501. package/src/aldehyde/layout3/header.tsx +187 -187
  502. package/src/aldehyde/layout3/main.tsx +29 -29
  503. package/src/aldehyde/layout3/page.tsx +110 -110
  504. package/src/aldehyde/layout3/sider.tsx +198 -198
  505. package/src/aldehyde/layout4/components/tabs-layout.tsx +110 -110
  506. package/src/aldehyde/layout4/css/header.less +196 -196
  507. package/src/aldehyde/layout4/css/main.less +154 -154
  508. package/src/aldehyde/layout4/css/sider.less +37 -37
  509. package/src/aldehyde/layout4/css/tabs-layout.less +42 -42
  510. package/src/aldehyde/layout4/header.tsx +190 -190
  511. package/src/aldehyde/layout4/main.tsx +29 -29
  512. package/src/aldehyde/layout4/page.tsx +125 -125
  513. package/src/aldehyde/layout4/sider.tsx +201 -201
  514. package/src/aldehyde/layout5/css/header.less +35 -35
  515. package/src/aldehyde/layout5/css/sider.less +18 -18
  516. package/src/aldehyde/layout5/header.tsx +204 -204
  517. package/src/aldehyde/layout5/page.tsx +107 -107
  518. package/src/aldehyde/layout5/sider.tsx +235 -235
  519. package/src/aldehyde/list/calendar/index.less +20 -20
  520. package/src/aldehyde/list/calendar/index.tsx +157 -157
  521. package/src/aldehyde/list/card-list/card-list-item.tsx +112 -112
  522. package/src/aldehyde/list/card-list/index.less +154 -154
  523. package/src/aldehyde/list/card-list/index.tsx +83 -83
  524. package/src/aldehyde/list/gantt/index.less +8 -8
  525. package/src/aldehyde/list/gantt/index.tsx +508 -508
  526. package/src/aldehyde/list/vertical-list/index.less +208 -208
  527. package/src/aldehyde/list/vertical-list/index.tsx +55 -55
  528. package/src/aldehyde/list/vertical-list/item.tsx +136 -136
  529. package/src/aldehyde/locale/LocaleButton.tsx +48 -48
  530. package/src/aldehyde/locale/LocaleProvider.tsx +265 -265
  531. package/src/aldehyde/locale/langMp.ts +45 -45
  532. package/src/aldehyde/locale/translate.ts +80 -80
  533. package/src/aldehyde/locale/useLocale.ts +72 -72
  534. package/src/aldehyde/login/context-setter.tsx +130 -130
  535. package/src/aldehyde/login/index.css +19 -19
  536. package/src/aldehyde/login/login.tsx +255 -255
  537. package/src/aldehyde/login/router-login.tsx +107 -107
  538. package/src/aldehyde/login/vertify/index.css +143 -143
  539. package/src/aldehyde/login/vertify/index.tsx +360 -360
  540. package/src/aldehyde/login/vertify/tool.ts +13 -13
  541. package/src/aldehyde/login2/login-page.tsx +92 -92
  542. package/src/aldehyde/login2/login.tsx +227 -227
  543. package/src/aldehyde/login3/index.less +136 -136
  544. package/src/aldehyde/login3/login-page.tsx +71 -71
  545. package/src/aldehyde/lowcode-components/act-table/index.less +26 -26
  546. package/src/aldehyde/lowcode-components/act-table/index.tsx +139 -139
  547. package/src/aldehyde/lowcode-components/assets/lowcode-constant.tsx +12 -12
  548. package/src/aldehyde/lowcode-components/bar-chart/index.tsx +272 -268
  549. package/src/aldehyde/lowcode-components/base-button/index.less +7 -7
  550. package/src/aldehyde/lowcode-components/base-button/index.tsx +197 -197
  551. package/src/aldehyde/lowcode-components/base-image/index.tsx +220 -220
  552. package/src/aldehyde/lowcode-components/base-map/index.tsx +292 -292
  553. package/src/aldehyde/lowcode-components/base-radio/index.less +23 -23
  554. package/src/aldehyde/lowcode-components/base-radio/index.tsx +157 -157
  555. package/src/aldehyde/lowcode-components/base-table/index.tsx +268 -268
  556. package/src/aldehyde/lowcode-components/base-tabs/index.less +14 -14
  557. package/src/aldehyde/lowcode-components/base-tabs/index.tsx +183 -183
  558. package/src/aldehyde/lowcode-components/base-text/index.tsx +58 -58
  559. package/src/aldehyde/lowcode-components/border/border1/index.tsx +70 -70
  560. package/src/aldehyde/lowcode-components/border/border10/index.less +26 -26
  561. package/src/aldehyde/lowcode-components/border/border10/index.tsx +45 -45
  562. package/src/aldehyde/lowcode-components/border/border11/index.less +17 -17
  563. package/src/aldehyde/lowcode-components/border/border11/index.tsx +232 -232
  564. package/src/aldehyde/lowcode-components/border/border12/index.less +13 -13
  565. package/src/aldehyde/lowcode-components/border/border12/index.tsx +115 -115
  566. package/src/aldehyde/lowcode-components/border/border13/index.less +13 -13
  567. package/src/aldehyde/lowcode-components/border/border13/index.tsx +69 -69
  568. package/src/aldehyde/lowcode-components/border/border2/index.less +17 -17
  569. package/src/aldehyde/lowcode-components/border/border2/index.tsx +51 -51
  570. package/src/aldehyde/lowcode-components/border/border3/index.less +25 -25
  571. package/src/aldehyde/lowcode-components/border/border3/index.tsx +61 -61
  572. package/src/aldehyde/lowcode-components/border/border4/index.less +72 -72
  573. package/src/aldehyde/lowcode-components/border/border4/index.tsx +79 -79
  574. package/src/aldehyde/lowcode-components/border/border5/index.less +35 -35
  575. package/src/aldehyde/lowcode-components/border/border5/index.tsx +75 -75
  576. package/src/aldehyde/lowcode-components/border/border6/index.less +17 -17
  577. package/src/aldehyde/lowcode-components/border/border6/index.tsx +60 -60
  578. package/src/aldehyde/lowcode-components/border/border7/index.less +26 -26
  579. package/src/aldehyde/lowcode-components/border/border7/index.tsx +75 -75
  580. package/src/aldehyde/lowcode-components/border/border8/index.less +13 -13
  581. package/src/aldehyde/lowcode-components/border/border8/index.tsx +84 -84
  582. package/src/aldehyde/lowcode-components/border/border9/index.less +13 -13
  583. package/src/aldehyde/lowcode-components/border/border9/index.tsx +154 -154
  584. package/src/aldehyde/lowcode-components/capsule-bar-chart/index.tsx +290 -290
  585. package/src/aldehyde/lowcode-components/carousel/index.tsx +218 -218
  586. package/src/aldehyde/lowcode-components/circular-progress-chart/index.tsx +263 -263
  587. package/src/aldehyde/lowcode-components/column-3d-chart/index.tsx +442 -438
  588. package/src/aldehyde/lowcode-components/column-chart/index.tsx +297 -293
  589. package/src/aldehyde/lowcode-components/data-number/index.tsx +219 -219
  590. package/src/aldehyde/lowcode-components/data.d.ts +19 -19
  591. package/src/aldehyde/lowcode-components/decoration/decoration1/index.less +7 -7
  592. package/src/aldehyde/lowcode-components/decoration/decoration1/index.tsx +153 -153
  593. package/src/aldehyde/lowcode-components/decoration/decoration10/index.less +5 -5
  594. package/src/aldehyde/lowcode-components/decoration/decoration10/index.tsx +89 -89
  595. package/src/aldehyde/lowcode-components/decoration/decoration11/index.less +5 -5
  596. package/src/aldehyde/lowcode-components/decoration/decoration11/index.tsx +133 -133
  597. package/src/aldehyde/lowcode-components/decoration/decoration2/index.less +6 -6
  598. package/src/aldehyde/lowcode-components/decoration/decoration2/index.tsx +61 -61
  599. package/src/aldehyde/lowcode-components/decoration/decoration3/index.less +7 -7
  600. package/src/aldehyde/lowcode-components/decoration/decoration3/index.tsx +87 -87
  601. package/src/aldehyde/lowcode-components/decoration/decoration4/index.less +29 -29
  602. package/src/aldehyde/lowcode-components/decoration/decoration4/index.tsx +53 -53
  603. package/src/aldehyde/lowcode-components/decoration/decoration5/index.less +3 -3
  604. package/src/aldehyde/lowcode-components/decoration/decoration5/index.tsx +116 -116
  605. package/src/aldehyde/lowcode-components/decoration/decoration6/index.less +7 -7
  606. package/src/aldehyde/lowcode-components/decoration/decoration6/index.tsx +121 -121
  607. package/src/aldehyde/lowcode-components/decoration/decoration7/index.less +4 -4
  608. package/src/aldehyde/lowcode-components/decoration/decoration7/index.tsx +70 -70
  609. package/src/aldehyde/lowcode-components/decoration/decoration8/index.less +14 -14
  610. package/src/aldehyde/lowcode-components/decoration/decoration8/index.tsx +122 -122
  611. package/src/aldehyde/lowcode-components/decoration/decoration9/index.less +4 -4
  612. package/src/aldehyde/lowcode-components/decoration/decoration9/index.tsx +196 -196
  613. package/src/aldehyde/lowcode-components/effectScatter-map/index.tsx +315 -315
  614. package/src/aldehyde/lowcode-components/effectScatter-map-3d/index.tsx +419 -419
  615. package/src/aldehyde/lowcode-components/gauge-chart/index.tsx +254 -254
  616. package/src/aldehyde/lowcode-components/index.ts +130 -130
  617. package/src/aldehyde/lowcode-components/line-bar-chart/index.tsx +304 -300
  618. package/src/aldehyde/lowcode-components/line-chart/index.tsx +294 -290
  619. package/src/aldehyde/lowcode-components/liquid-chart/index.tsx +250 -250
  620. package/src/aldehyde/lowcode-components/lowcode-view/component/assets.ts +478 -478
  621. package/src/aldehyde/lowcode-components/lowcode-view/component/component-controller.ts +153 -153
  622. package/src/aldehyde/lowcode-components/lowcode-view/component/component-definition.ts +23 -23
  623. package/src/aldehyde/lowcode-components/lowcode-view/component/loading.tsx +20 -20
  624. package/src/aldehyde/lowcode-components/lowcode-view/component/util.ts +27 -27
  625. package/src/aldehyde/lowcode-components/lowcode-view/index.less +19 -19
  626. package/src/aldehyde/lowcode-components/lowcode-view/index.tsx +277 -277
  627. package/src/aldehyde/lowcode-components/lowcode-view/interface.ts +189 -189
  628. package/src/aldehyde/lowcode-components/pie-chart/index.tsx +353 -349
  629. package/src/aldehyde/lowcode-components/progress-chart/index.tsx +295 -295
  630. package/src/aldehyde/lowcode-components/radar-chart/index.tsx +322 -322
  631. package/src/aldehyde/lowcode-components/search-form/index.less +25 -25
  632. package/src/aldehyde/lowcode-components/search-form/index.tsx +121 -121
  633. package/src/aldehyde/lowcode-components/stroke-animation/index.tsx +219 -219
  634. package/src/aldehyde/module/block-menu-tree-drawer.tsx +118 -118
  635. package/src/aldehyde/module/criteria-page.tsx1 +175 -175
  636. package/src/aldehyde/module/draggable-modal.tsx +66 -66
  637. package/src/aldehyde/module/dtmpl-edit-card.tsx +477 -467
  638. package/src/aldehyde/module/dtmpl-edit-drawer.tsx +23 -23
  639. package/src/aldehyde/module/dtmpl-edit-modal.tsx +25 -25
  640. package/src/aldehyde/module/dtmpl-edit-page.tsx +597 -588
  641. package/src/aldehyde/module/dtmpl-editor.tsx +165 -165
  642. package/src/aldehyde/module/dtmpl-view-card.tsx +64 -64
  643. package/src/aldehyde/module/dtmpl-view-drawer.tsx +71 -71
  644. package/src/aldehyde/module/dtmpl-view-modal.tsx +56 -56
  645. package/src/aldehyde/module/embed-dtmpl-edit-page.tsx +137 -137
  646. package/src/aldehyde/module/index.less +4 -4
  647. package/src/aldehyde/module/ltmpl-drawer.tsx +60 -60
  648. package/src/aldehyde/module/ltmpl-modal.tsx +63 -63
  649. package/src/aldehyde/module/ltmpl-table.tsx +379 -379
  650. package/src/aldehyde/module/ttmpl-tree.tsx +47 -47
  651. package/src/aldehyde/routable/dtmpl-route.tsx +173 -173
  652. package/src/aldehyde/routable/import-route.tsx +35 -35
  653. package/src/aldehyde/routable/index.less +25 -25
  654. package/src/aldehyde/routable/ltmpl-route.tsx +539 -539
  655. package/src/aldehyde/routable/splitview-ltmpl-route.tsx +377 -377
  656. package/src/aldehyde/routable/ttmpl-route.tsx +93 -93
  657. package/src/aldehyde/routable/withroute.tsx +36 -36
  658. package/src/aldehyde/sso-Login/index.tsx +73 -73
  659. package/src/aldehyde/sso-Login/service/index.js +16 -16
  660. package/src/aldehyde/sso-Login/service/login.js +75 -75
  661. package/src/aldehyde/table/act-table.tsx +1844 -1838
  662. package/src/aldehyde/table/column/column-builder.tsx +876 -876
  663. package/src/aldehyde/table/column/column-selector.tsx +130 -130
  664. package/src/aldehyde/table/column/index.less +85 -85
  665. package/src/aldehyde/table/column/summary-builder.tsx +712 -712
  666. package/src/aldehyde/table/column/theme-color-getter.tsx +25 -25
  667. package/src/aldehyde/table/control-table-x-axis-wrapper.tsx +80 -80
  668. package/src/aldehyde/table/index.css +211 -211
  669. package/src/aldehyde/table/l2-act-table.tsx +91 -91
  670. package/src/aldehyde/table/modal-select-table.tsx +308 -308
  671. package/src/aldehyde/table/page-chart.less +10 -0
  672. package/src/aldehyde/table/page-chart.tsx +196 -0
  673. package/src/aldehyde/table/page-config-button.tsx +203 -203
  674. package/src/aldehyde/table/pagination.css +14 -14
  675. package/src/aldehyde/table/pagination.tsx +81 -81
  676. package/src/aldehyde/table/query-table.tsx +668 -668
  677. package/src/aldehyde/table/relation-table.tsx +1078 -1078
  678. package/src/aldehyde/table/report-table.tsx +125 -125
  679. package/src/aldehyde/table/resizable-table.tsx +97 -97
  680. package/src/aldehyde/table/row-table.tsx +23 -0
  681. package/src/aldehyde/table/select-table.tsx +559 -559
  682. package/src/aldehyde/table/selected-rows-card.tsx +78 -78
  683. package/src/aldehyde/table/stat/restat.tsx +122 -122
  684. package/src/aldehyde/table/table-util.tsx +25 -25
  685. package/src/aldehyde/tmpl/control-type-supportor.tsx +154 -154
  686. package/src/aldehyde/tmpl/hc-data-source.tsx +574 -574
  687. package/src/aldehyde/tmpl/hcservice-v3.tsx +1590 -1590
  688. package/src/aldehyde/tmpl/interface.tsx +936 -924
  689. package/src/aldehyde/tmpl/model-struc-v3.tsx +111 -111
  690. package/src/aldehyde/tmpl/superagent.js +146 -146
  691. package/src/aldehyde/tmpl/tmpl-config-analysis.tsx +585 -585
  692. package/src/aldehyde/tmpl/web-socket.ts +366 -366
  693. package/src/aldehyde/tree/act-tree.tsx +217 -217
  694. package/src/aldehyde/tree/block-menu-auth-tree.tsx +189 -189
  695. package/src/aldehyde/tree/index.css +22 -22
  696. package/src/aldehyde/tree/navigation-tree.tsx +39 -39
  697. package/src/aldehyde/tree/tmpl-tree.tsx +751 -751
  698. package/src/aldehyde/tree/tree-node.tsx +73 -73
  699. package/src/aldehyde/tree/tree-utils.tsx +317 -317
  700. package/src/aldehyde/units/EncryptUtils.js +37 -37
  701. package/src/aldehyde/units/image.d.ts +7 -7
  702. package/src/aldehyde/units/index.tsx +1367 -1367
  703. package/src/aldehyde/units/storage.js +2 -2
  704. package/src/aldehyde/utils/dsu.ts +27 -27
  705. package/src/aldehyde/welcome/HCWelcome.js +404 -404
  706. package/src/aldehyde/welcome/HCWelcome1.js +259 -259
  707. package/src/aldehyde/welcome/components/menu-card.less +96 -96
  708. package/src/aldehyde/welcome/components/menu-card.tsx +70 -70
  709. package/src/aldehyde/welcome/components/page-card.less +49 -49
  710. package/src/aldehyde/welcome/components/page-card.tsx +97 -97
  711. package/src/aldehyde/welcome/components/quick-entrance.less +120 -120
  712. package/src/aldehyde/welcome/components/quick-entrance.tsx +80 -80
  713. package/src/aldehyde/welcome/components/user-menus.less +192 -192
  714. package/src/aldehyde/welcome/components/user-menus.tsx +279 -279
  715. package/src/aldehyde/welcome/components/workbench.less +118 -118
  716. package/src/aldehyde/welcome/components/workbench.tsx +146 -146
  717. package/src/aldehyde/welcome/index.css +13 -13
@@ -1,1414 +1,1415 @@
1
- import Konva from 'konva';
2
- import { LinkType, BaseDraw, Draw, Render, LinkDrawPoint, LinkDrawPair, ManualPointsMap, ManualPoint } from '../types';
3
- import * as Draws from '../draws';
4
- import { nanoid } from 'nanoid';
5
- import aStar from '../utils/a-star';
6
- import { BezierSceneFunc } from '../utils/bezier-scene-func';
7
-
8
- // 绘制连线
9
-
10
- export interface LinkDrawOption {
11
- size: number
12
- }
13
-
14
- // 连接线(临时)
15
- export interface LinkDrawState {
16
- linkingLine: {
17
- group: Konva.Group;
18
- circle: Konva.Circle;
19
- line: Konva.Line
20
- } | null;
21
- linkType: LinkType; // 连接线类型
22
- linkManualing: boolean // 是否 正在操作拐点
23
- }
24
-
25
- type Area = {
26
- x1: number;
27
- y1: number;
28
- x2: number;
29
- y2: number;
30
- }
31
-
32
- export class LinkDraw extends BaseDraw implements Draw {
33
- option: LinkDrawOption;
34
-
35
- state: LinkDrawState = {
36
- linkingLine: null,
37
- linkType: "curve",
38
- linkManualing: false
39
- }
40
-
41
- constructor(render: Render, layer: Konva.Layer, option: LinkDrawOption) {
42
- super(render, layer);
43
- this.option = option;
44
- this.group.name(this.constructor.name);
45
- }
46
-
47
- // 元素(连接点们)最小区域(绝对值)
48
- getGroupLinkArea(group?: Konva.Group): Area {
49
- let area: Area = { x1: 0, y1: 0, x2: 0, y2: 0 };
50
- if (group) {
51
- const stageState = this.render.getStageState(); // stage 状态
52
- const anchors = group.find('.link-anchor');
53
- const positions = anchors.map((o) => o.absolutePosition());
54
- area = {
55
- x1: Math.min(...positions.map((o) => o.x)) - stageState.x,
56
- y1: Math.min(...positions.map((o) => o.y)) - stageState.y,
57
- x2: Math.max(...positions.map((o) => o.x)) - stageState.x,
58
- y2: Math.max(...positions.map((o) => o.y)) - stageState.y
59
- };
60
- }
61
- return area;
62
- }
63
-
64
- // 连线不可通过区域
65
- getGroupForbiddenArea(groupArea: Area, gap: number): Area {
66
- const area: Area = {
67
- x1: groupArea.x1 - gap,
68
- y1: groupArea.y1 - gap,
69
- x2: groupArea.x2 + gap,
70
- y2: groupArea.y2 + gap
71
- };
72
- return area;
73
- }
74
-
75
- // 连线通过区域
76
- getGroupAccessArea(groupArea: Area, gap: number): Area {
77
- const area: Area = {
78
- x1: groupArea.x1 - gap,
79
- y1: groupArea.y1 - gap,
80
- x2: groupArea.x2 + gap,
81
- y2: groupArea.y2 + gap
82
- };
83
- return area;
84
- }
85
-
86
- // 两区域扩展
87
- getGroupPairArea(groupArea1: Area, groupArea2: Area): Area {
88
- const area: Area = {
89
- x1: Math.min(groupArea1.x1, groupArea2.x1),
90
- y1: Math.min(groupArea1.y1, groupArea2.y1),
91
- x2: Math.max(groupArea1.x2, groupArea2.x2),
92
- y2: Math.max(groupArea1.y2, groupArea2.y2)
93
- };
94
- return area;
95
- }
96
-
97
- // 两区域最短距离
98
- getGroupPairDistance(groupArea1: Area, groupArea2: Area): number {
99
- const xs = [groupArea1.x1, groupArea1.x2, groupArea2.x1, groupArea2.x2];
100
- const maxX = Math.max(...xs);
101
- const minX = Math.min(...xs);
102
- const dx = maxX - minX - (groupArea1.x2 - groupArea1.x1 + (groupArea2.x2 - groupArea2.x1));
103
- const ys = [groupArea1.y1, groupArea1.y2, groupArea2.y1, groupArea2.y2];
104
- const maxY = Math.max(...ys);
105
- const minY = Math.min(...ys);
106
- const dy = maxY - minY - (groupArea1.y2 - groupArea1.y1 + (groupArea2.y2 - groupArea2.y1));
107
- return this.render.toBoardValue(Math.min(this.render.bgSize * 0.5, Math.max(dx < 6 ? 6 : dx, dy < 6 ? 6 : dy) * 0.5));
108
- }
109
-
110
- // 两区域空隙中点
111
- getGroupPairCenter(groupArea1: Area, groupArea2: Area): Konva.Vector2d {
112
- return { x: (groupArea2.x1 + groupArea1.x2) * 0.5, y: (groupArea2.y1 + groupArea1.y2) * 0.5 };
113
- }
114
-
115
- // 连接出入口
116
- getEntry(anchor: Konva.Node, groupForbiddenArea: Area, gap: number): Konva.Vector2d {
117
- const stageState = this.render.getStageState();
118
- const fromPos = anchor.absolutePosition();
119
- // 默认为 起点/终点 位置(无 direction 时的值)
120
- let x = fromPos.x - stageState.x;
121
- let y = fromPos.y - stageState.y;
122
- const direction = anchor.attrs.direction;
123
- // 定义了 direction 的时候
124
- if (direction) {
125
- // 取整 连接点 锚点 旋转角度(保留 1 位小数点)
126
- const rotate = Math.round(anchor.getAbsoluteRotation() * 10) / 10;
127
- if (rotate === -45) {
128
- if (direction === 'top') {
129
- x = groupForbiddenArea.x1;
130
- y = groupForbiddenArea.y1;
131
- } else if (direction === 'bottom') {
132
- x = groupForbiddenArea.x2;
133
- y = groupForbiddenArea.y2;
134
- } else if (direction === 'left') {
135
- x = groupForbiddenArea.x1;
136
- y = groupForbiddenArea.y2;
137
- } else if (direction === 'right') {
138
- x = groupForbiddenArea.x2;
139
- y = groupForbiddenArea.y1;
140
- }
141
- } else if (rotate === 45) {
142
- if (direction === 'top') {
143
- x = groupForbiddenArea.x2;
144
- y = groupForbiddenArea.y1;
145
- } else if (direction === 'bottom') {
146
- x = groupForbiddenArea.x1;
147
- y = groupForbiddenArea.y2;
148
- } else if (direction === 'left') {
149
- x = groupForbiddenArea.x1;
150
- y = groupForbiddenArea.y1;
151
- } else if (direction === 'right') {
152
- x = groupForbiddenArea.x2;
153
- y = groupForbiddenArea.y2;
154
- }
155
- } else if (rotate === 135) {
156
- if (direction === 'top') {
157
- x = groupForbiddenArea.x2;
158
- y = groupForbiddenArea.y2;
159
- } else if (direction === 'bottom') {
160
- x = groupForbiddenArea.x1;
161
- y = groupForbiddenArea.y1;
162
- } else if (direction === 'left') {
163
- x = groupForbiddenArea.x2;
164
- y = groupForbiddenArea.y1;
165
- } else if (direction === 'right') {
166
- x = groupForbiddenArea.x1;
167
- y = groupForbiddenArea.y2;
168
- }
169
- } else if (rotate === -135) {
170
- if (direction === 'top') {
171
- x = groupForbiddenArea.x1;
172
- y = groupForbiddenArea.y2;
173
- } else if (direction === 'bottom') {
174
- x = groupForbiddenArea.x2;
175
- y = groupForbiddenArea.y1;
176
- } else if (direction === 'left') {
177
- x = groupForbiddenArea.x2;
178
- y = groupForbiddenArea.y2;
179
- } else if (direction === 'right') {
180
- x = groupForbiddenArea.x1;
181
- y = groupForbiddenArea.y1;
182
- }
183
- } else if (rotate > -45 && rotate < 45) {
184
- const offset = gap * Math.tan((rotate * Math.PI) / 180);
185
- if (direction === 'top') {
186
- x = fromPos.x - stageState.x + offset;
187
- y = groupForbiddenArea.y1;
188
- } else if (direction === 'bottom') {
189
- x = fromPos.x - stageState.x - offset;
190
- y = groupForbiddenArea.y2;
191
- } else if (direction === 'left') {
192
- x = groupForbiddenArea.x1;
193
- y = fromPos.y - stageState.y - offset;
194
- } else if (direction === 'right') {
195
- x = groupForbiddenArea.x2;
196
- y = fromPos.y - stageState.y + offset;
197
- }
198
- } else if (rotate > 45 && rotate < 135) {
199
- const offset = gap * Math.atan(((90 - rotate) * Math.PI) / 180);
200
- if (direction === 'top') {
201
- x = groupForbiddenArea.x2;
202
- y = fromPos.y - stageState.y - offset;
203
- } else if (direction === 'bottom') {
204
- x = groupForbiddenArea.x1;
205
- y = fromPos.y - stageState.y + offset;
206
- } else if (direction === 'left') {
207
- x = fromPos.x - stageState.x - offset;
208
- y = groupForbiddenArea.y1;
209
- } else if (direction === 'right') {
210
- x = fromPos.x - stageState.x + offset;
211
- y = groupForbiddenArea.y2;
212
- }
213
- } else if ((rotate > 135 && rotate <= 180) || (rotate >= -180 && rotate < -135)) {
214
- const offset = gap * Math.tan((rotate * Math.PI) / 180);
215
- if (direction === 'top') {
216
- x = fromPos.x - stageState.x - offset;
217
- y = groupForbiddenArea.y2;
218
- } else if (direction === 'bottom') {
219
- x = fromPos.x - stageState.x + offset;
220
- y = groupForbiddenArea.y1;
221
- } else if (direction === 'left') {
222
- x = groupForbiddenArea.x2;
223
- y = fromPos.y - stageState.y + offset;
224
- } else if (direction === 'right') {
225
- x = groupForbiddenArea.x1;
226
- y = fromPos.y - stageState.y - offset;
227
- }
228
- } else if (rotate > -135 && rotate < -45) {
229
- const offset = gap * Math.atan(((90 + rotate) * Math.PI) / 180);
230
- if (direction === 'top') {
231
- x = groupForbiddenArea.x1;
232
- y = fromPos.y - stageState.y - offset;
233
- } else if (direction === 'bottom') {
234
- x = groupForbiddenArea.x2;
235
- y = fromPos.y - stageState.y + offset;
236
- } else if (direction === 'left') {
237
- x = fromPos.x - stageState.x - offset;
238
- y = groupForbiddenArea.y2;
239
- } else if (direction === 'right') {
240
- x = fromPos.x - stageState.x + offset;
241
- y = groupForbiddenArea.y1;
242
- }
243
- }
244
- }
245
- return { x, y } as Konva.Vector2d;
246
- }
247
-
248
- // 连接点信息
249
- getAnchorPos(anchor?: Konva.Node): Konva.Vector2d {
250
- const stageState = this.render.getStageState();
251
- return anchor ? { x: anchor.absolutePosition().x - stageState.x, y: anchor.absolutePosition().y - stageState.y } : { x: 0, y: 0 };
252
- }
253
-
254
- /**
255
- * 修改当前连接线类型
256
- * @param linkType LinkType
257
- */
258
- changeLinkType(linkType: LinkType) {
259
- this.state.linkType = linkType;
260
- this.render.emit('link-type-change', this.state.linkType);
261
- }
262
-
263
- override draw() {
264
- this.clear();
265
- const stageState = this.render.getStageState();
266
-
267
- // 所有层级的素材
268
- const groups = [
269
- ...(this.render.layer.find('.asset') as Konva.Group[]),
270
- ...(this.render.layer.find('.sub-asset') as Konva.Group[])
271
- ];
272
- const points = groups.reduce((ps, group) => ps.concat(Array.isArray(group.getAttr('points')) ? group.getAttr('points') : []), [] as LinkDrawPoint[]);
273
- const pairs = points.reduce((ps, point) => ps.concat(point.pairs ? point.pairs.filter((o) => !o.disabled) : []), [] as LinkDrawPair[]);
274
-
275
- // 连接线
276
- for (const pair of pairs) {
277
- // 多层素材,需要排除内部 pair
278
- // pair 也不能为 disabled
279
- if (pair.from.groupId !== pair.to.groupId && !pair.disabled) {
280
- const fromGroup = groups.find((o) => o.id() === pair.from.groupId);
281
- const fromPoint = points.find((o) => o.id === pair.from.pointId);
282
- const toGroup = groups.find((o) => o.id() === pair.to.groupId);
283
- const toPoint = points.find((o) => o.id === pair.to.pointId);
284
- if (pair.linkType === "manual") {
285
- // 折线
286
- if (fromGroup && toGroup && fromPoint && toPoint) {
287
- const fromAnchor = fromGroup.findOne(`#${fromPoint.id}`);
288
- const toAnchor = toGroup.findOne(`#${toPoint.id}`);
289
- // 锚点信息
290
- const fromAnchorPos = this.getAnchorPos(fromAnchor);
291
- const toAnchorPos = this.getAnchorPos(toAnchor);
292
- // 拐点(已拐)记录
293
- const manualPointsMap: ManualPointsMap = fromGroup.getAttr('manualPointsMap') ?? ({} as ManualPointsMap);
294
- const manualPoints = manualPointsMap[pair.id] ?? ([] as ManualPoint[]);
295
- // 连接点 + 拐点
296
- const linkPoints = [
297
- [this.render.toStageValue(fromAnchorPos.x), this.render.toStageValue(fromAnchorPos.y)],
298
- ...manualPoints.map((o) => [o.x, o.y]),
299
- [this.render.toStageValue(toAnchorPos.x), this.render.toStageValue(toAnchorPos.y)]
300
- ];
301
-
302
- // 连接线
303
- const linkLine = new Konva.Arrow({
304
- name: 'link-line',
305
- // 用于删除连接线
306
- groupId: fromGroup.id(),
307
- pointId: fromPoint.id,
308
- pairId: pair.id,
309
- linkType: pair.linkType,
310
- points: linkPoints.flat(),
311
- pointerAtBeginning: false,
312
- pointerAtEnding: false
313
- });
314
- linkLine.stroke(this.render.getLinkSettings(linkLine).stroke);
315
- linkLine.strokeWidth(this.render.getLinkSettings(linkLine).strokeWidth);
316
- linkLine.hitStrokeWidth(Math.max(this.render.getLinkSettings().strokeWidth, 10));
317
- linkLine.dash(this.render.linkTool.linkCurrent?.attrs.pairId === pair.id ? [1, 1] : []);
318
- linkLine.fill(this.render.getLinkSettings(linkLine).stroke);
319
- linkLine.pointerAtBeginning(this.render.getLinkSettings(linkLine).arrowStart);
320
- linkLine.pointerAtEnding(this.render.getLinkSettings(linkLine).arrowEnd);
321
- if (!this.render.config.readonly) {
322
- linkLine.on('pointerclick', () => this.render.linkTool.select(linkLine));
323
- linkLine.on('mouseenter', () => {
324
- linkLine.opacity(0.5);
325
- document.body.style.cursor = 'pointer';
326
- });
327
- linkLine.on('mouseleave', () => {
328
- linkLine.opacity(1);
329
- document.body.style.cursor = 'default';
330
- });
331
- }
332
- this.group.add(linkLine);
333
- if (!this.render.config.readonly) {
334
- // 正在拖动效果
335
- const manualingLine = new Konva.Line({
336
- name: 'manualing-line',
337
- stroke: '#ff0000',
338
- strokeWidth: 2,
339
- points: [],
340
- dash: [4, 4]
341
- });
342
- this.group.add(manualingLine);
343
- for (let i = 0; i < linkPoints.length - 1; i++) {
344
- const circle = new Konva.Circle({
345
- name: 'link-manual-point',
346
- id: nanoid(),
347
- pairId: pair.id,
348
- x: (linkPoints[i][0] + linkPoints[i + 1][0]) / 2,
349
- y: (linkPoints[i][1] + linkPoints[i + 1][1]) / 2,
350
- radius: this.render.toStageValue(this.render.bgSize / 2),
351
- stroke: 'rgba(0,0,255,0.2)',
352
- strokeWidth: this.render.toStageValue(1),
353
- linkManualIndex: i // 当前拐点位置
354
- });
355
- // hover 效果
356
- circle.on('mouseenter', () => {
357
- circle.stroke('rgba(0,0,255,0.8)');
358
- document.body.style.cursor = 'pointer';
359
- });
360
- circle.on('mouseleave', () => {
361
- if (!circle.attrs.dragStart) {
362
- circle.stroke('rgba(0,0,255,0.1)');
363
- document.body.style.cursor = 'default';
364
- }
365
- });
366
-
367
- // 拐点操作
368
- circle.on('mousedown', () => {
369
- const pos = circle.getAbsolutePosition();
370
- // 记录操作开始状态
371
- circle.setAttrs({
372
- // 开始坐标
373
- dragStartX: pos.x,
374
- dragStartY: pos.y,
375
- // 正在操作
376
- dragStart: true
377
- });
378
- // 标记状态 - 正在操作拐点
379
- this.state.linkManualing = true;
380
- });
381
- this.render.stage.on('mousemove', () => {
382
- if (circle.attrs.dragStart) {
383
- // 正在操作
384
- const pos = this.render.stage.getPointerPosition();
385
- if (pos) {
386
- // 磁贴
387
- const { pos: transformerPos } = this.render.attractTool.attractPoint(pos);
388
- // 移动拐点
389
- circle.setAbsolutePosition(transformerPos);
390
- // 正在拖动效果
391
- const tempPoints = [...linkPoints];
392
- tempPoints.splice(circle.attrs.linkManualIndex + 1, 0, [
393
- this.render.toStageValue(transformerPos.x - stageState.x),
394
- this.render.toStageValue(transformerPos.y - stageState.y)
395
- ]);
396
- manualingLine.points(tempPoints.flat());
397
- }
398
- }
399
- });
400
- circle.on('mouseup', () => {
401
- const pos = circle.getAbsolutePosition();
402
- if (
403
- Math.abs(pos.x - circle.attrs.dragStartX) > this.option.size ||
404
- Math.abs(pos.y - circle.attrs.dragStartY) > this.option.size
405
- ) {
406
- // 操作移动距离达到阈值
407
- const stageState = this.render.getStageState();
408
- // 记录(插入)拐点
409
- manualPoints.splice(circle.attrs.linkManualIndex, 0, {
410
- x: this.render.toStageValue(pos.x - stageState.x),
411
- y: this.render.toStageValue(pos.y - stageState.y)
412
- });
413
- manualPointsMap[pair.id] = manualPoints;
414
- fromGroup.setAttr('manualPointsMap', manualPointsMap);
415
- }
416
-
417
- // 操作结束
418
- circle.setAttrs({ dragStart: false });
419
-
420
- // state 操作结束
421
- this.state.linkManualing = false;
422
-
423
- // 销毁
424
- circle.destroy();
425
- manualingLine.destroy();
426
-
427
- // 更新历史
428
- this.render.updateHistory();
429
-
430
- // 对齐线清除
431
- this.render.attractTool.alignLinesClear();
432
-
433
- // 重绘
434
- this.render.redraw([
435
- Draws.LinkDraw.name,
436
- Draws.RulerDraw.name,
437
- Draws.PreviewDraw.name
438
- ]);
439
- })
440
-
441
- this.group.add(circle);
442
- }
443
-
444
- // 拐点(已拐)
445
- for (let i = 1; i < linkPoints.length - 1; i++) {
446
- const circle = new Konva.Circle({
447
- name: 'link-manual-point',
448
- id: nanoid(),
449
- pairId: pair.id,
450
- x: linkPoints[i][0],
451
- y: linkPoints[i][1],
452
- radius: this.render.toStageValue(this.render.bgSize / 2),
453
- stroke: 'rgba(0,100,0,0.2)',
454
- strokeWidth: this.render.toStageValue(1),
455
- linkManualIndex: i // 当前拐点位置
456
- });
457
-
458
- // hover 效果
459
- circle.on('mouseenter', () => {
460
- circle.stroke('rgba(0,100,0,1)');
461
- document.body.style.cursor = 'pointer';
462
- });
463
- circle.on('mouseleave', () => {
464
- if (!circle.attrs.dragStart) {
465
- circle.stroke('rgba(0,100,0,0.1)');
466
- document.body.style.cursor = 'default';
467
- }
468
- });
469
-
470
- // 拐点操作
471
- circle.on('mousedown', () => {
472
- const pos = circle.getAbsolutePosition();
473
- // 记录操作开始状态
474
- circle.setAttrs({
475
- dragStartX: pos.x,
476
- dragStartY: pos.y,
477
- dragStart: true
478
- });
479
-
480
- // 标记状态 - 正在操作拐点
481
- this.state.linkManualing = true;
482
- })
483
- this.render.stage.on('mousemove', () => {
484
- if (circle.attrs.dragStart) {
485
- // 正在操作
486
- const pos = this.render.stage.getPointerPosition();
487
- if (pos) {
488
- // 磁贴
489
- const { pos: transformerPos } = this.render.attractTool.attractPoint(pos);
490
- // 移动拐点
491
- circle.setAbsolutePosition(transformerPos);
492
- // 正在拖动效果
493
- const tempPoints = [...linkPoints];
494
- tempPoints[circle.attrs.linkManualIndex] = [
495
- this.render.toStageValue(transformerPos.x - stageState.x),
496
- this.render.toStageValue(transformerPos.y - stageState.y)
497
- ];
498
- manualingLine.points(tempPoints.flat());
499
- }
500
- }
501
- });
502
- circle.on('mouseup', () => {
503
- const pos = circle.getAbsolutePosition();
504
- if (
505
- Math.abs(pos.x - circle.attrs.dragStartX) > this.option.size ||
506
- Math.abs(pos.y - circle.attrs.dragStartY) > this.option.size
507
- ) {
508
- // 操作移动距离达到阈值
509
- const stageState = this.render.getStageState();
510
- // 记录(更新)拐点
511
- manualPoints[circle.attrs.linkManualIndex - 1] = {
512
- x: this.render.toStageValue(pos.x - stageState.x),
513
- y: this.render.toStageValue(pos.y - stageState.y)
514
- };
515
- manualPointsMap[pair.id] = manualPoints;
516
- fromGroup.setAttr('manualPointsMap', manualPointsMap);
517
- }
518
- // 操作结束
519
- circle.setAttrs({ dragStart: false });
520
- // state 操作结束
521
- this.state.linkManualing = false;
522
- // 销毁
523
- circle.destroy();
524
- manualingLine.destroy();
525
- // 更新历史
526
- this.render.updateHistory();
527
- // 对齐线清除
528
- this.render.attractTool.alignLinesClear();
529
- // 重绘
530
- this.render.redraw([
531
- Draws.LinkDraw.name,
532
- Draws.RulerDraw.name,
533
- Draws.PreviewDraw.name
534
- ]);
535
- })
536
- this.group.add(circle);
537
- }
538
- }
539
- }
540
- } else if (pair.linkType === "curve") {
541
- // 曲线
542
- if (fromGroup && toGroup && fromPoint && toPoint) {
543
- const fromAnchor = fromGroup.findOne(`#${fromPoint.id}`);
544
- const toAnchor = toGroup.findOne(`#${toPoint.id}`);
545
- // 锚点信息
546
- const fromAnchorPos = this.getAnchorPos(fromAnchor);
547
- const toAnchorPos = this.getAnchorPos(toAnchor);
548
- // 拐点(已拐)记录
549
- const manualPointsMap: ManualPointsMap = fromGroup.getAttr('manualPointsMap') ?? ({} as ManualPointsMap);
550
- const manualPoints = manualPointsMap[pair.id] ?? ([] as ManualPoint[]);
551
- // 连接点 + 拐点
552
- const linkPoints = [
553
- [
554
- this.render.toStageValue(fromAnchorPos.x),
555
- this.render.toStageValue(fromAnchorPos.y)
556
- ],
557
- ...manualPoints.map((o) => [o.x, o.y]),
558
- [this.render.toStageValue(toAnchorPos.x), this.render.toStageValue(toAnchorPos.y)]
559
- ];
560
-
561
- // 连接线
562
- const linkLine = new Konva.Arrow({
563
- name: 'link-line',
564
- // 用于删除连接线
565
- groupId: fromGroup.id(),
566
- pointId: fromPoint.id,
567
- pairId: pair.id,
568
- linkType: pair.linkType,
569
- points: linkPoints.flat(),
570
- pointerAtBeginning: false,
571
- pointerAtEnding: false
572
- });
573
- linkLine.stroke(this.render.getLinkSettings(linkLine).stroke);
574
- linkLine.strokeWidth(this.render.getLinkSettings(linkLine).strokeWidth);
575
- linkLine.hitStrokeWidth(Math.max(this.render.getLinkSettings().strokeWidth, 10));
576
- linkLine.dash(this.render.linkTool.linkCurrent?.attrs.pairId === pair.id ? [1, 1] : []);
577
- linkLine.fill(this.render.getLinkSettings(linkLine).stroke);
578
- linkLine.pointerAtBeginning(this.render.getLinkSettings(linkLine).arrowStart);
579
- linkLine.pointerAtEnding(this.render.getLinkSettings(linkLine).arrowEnd);
580
- linkLine.tension(this.render.getLinkSettings(linkLine).tension || 0);
581
- if (!this.render.config.readonly) {
582
- linkLine.on('pointerclick', () => this.render.linkTool.select(linkLine));
583
- linkLine.on('mouseenter', () => {
584
- linkLine.opacity(0.5);
585
- document.body.style.cursor = 'pointer';
586
- });
587
- linkLine.on('mouseleave', () => {
588
- linkLine.opacity(1);
589
- document.body.style.cursor = 'default';
590
- });
591
- }
592
- this.group.add(linkLine);
593
- if (!this.render.config.readonly) {
594
- // 正在拖动效果
595
- const manualingLine = new Konva.Arrow({
596
- name: 'manualing-line',
597
- stroke: '#ff0000',
598
- strokeWidth: 2,
599
- points: [],
600
- dash: [4, 4],
601
- pointerAtBeginning: false,
602
- pointerAtEnding: false,
603
- tension: this.render.getLinkSettings(linkLine).tension
604
- });
605
- this.group.add(manualingLine);
606
- // 拐点(待拐)
607
- for (let i = 0; i < linkPoints.length - 1; i++) {
608
- const circle = new Konva.Circle({
609
- name: 'link-manual-point',
610
- id: nanoid(),
611
- pairId: pair.id,
612
- x: (linkPoints[i][0] + linkPoints[i + 1][0]) / 2,
613
- y: (linkPoints[i][1] + linkPoints[i + 1][1]) / 2,
614
- radius: this.render.toStageValue(this.render.bgSize / 2),
615
- stroke: 'rgba(0,0,255,0.2)',
616
- strokeWidth: this.render.toStageValue(1),
617
- linkManualIndex: i // 当前拐点位置
618
- });
619
- // hover 效果
620
- circle.on('mouseenter', () => {
621
- circle.stroke('rgba(0,0,255,0.8)');
622
- document.body.style.cursor = 'pointer';
623
- });
624
- circle.on('mouseleave', () => {
625
- if (!circle.attrs.dragStart) {
626
- circle.stroke('rgba(0,0,255,0.1)');
627
- document.body.style.cursor = 'default';
628
- }
629
- });
630
- // 拐点操作
631
- circle.on('mousedown', () => {
632
- const pos = circle.getAbsolutePosition();
633
- // 记录操作开始状态
634
- circle.setAttrs({
635
- // 开始坐标
636
- dragStartX: pos.x,
637
- dragStartY: pos.y,
638
- // 正在操作
639
- dragStart: true
640
- });
641
- // 标记状态 - 正在操作拐点
642
- this.state.linkManualing = true;
643
- });
644
- this.render.stage.on('mousemove', () => {
645
- if (circle.attrs.dragStart) {
646
- // 正在操作
647
- const pos = this.render.stage.getPointerPosition();
648
- if (pos) {
649
- // 磁贴
650
- const { pos: transformerPos } = this.render.attractTool.attractPoint(pos);
651
- // 移动拐点
652
- circle.setAbsolutePosition(transformerPos);
653
- // 正在拖动效果
654
- const tempPoints = [...linkPoints];
655
- tempPoints.splice(circle.attrs.linkManualIndex + 1, 0, [
656
- this.render.toStageValue(transformerPos.x - stageState.x),
657
- this.render.toStageValue(transformerPos.y - stageState.y)
658
- ]);
659
- manualingLine.points(tempPoints.flat());
660
- }
661
- }
662
- });
663
- circle.on('mouseup', () => {
664
- const pos = circle.getAbsolutePosition();
665
- if (
666
- Math.abs(pos.x - circle.attrs.dragStartX) > this.option.size ||
667
- Math.abs(pos.y - circle.attrs.dragStartY) > this.option.size
668
- ) {
669
- // 操作移动距离达到阈值
670
- const stageState = this.render.getStageState();
671
- // 记录(插入)拐点
672
- manualPoints.splice(circle.attrs.linkManualIndex, 0, {
673
- x: this.render.toStageValue(pos.x - stageState.x),
674
- y: this.render.toStageValue(pos.y - stageState.y)
675
- });
676
- manualPointsMap[pair.id] = manualPoints;
677
- fromGroup.setAttr('manualPointsMap', manualPointsMap);
678
- }
679
- // 操作结束
680
- circle.setAttrs({ dragStart: false });
681
- // state 操作结束
682
- this.state.linkManualing = false;
683
- // 销毁
684
- circle.destroy();
685
- manualingLine.destroy();
686
- // 更新历史
687
- this.render.updateHistory();
688
- // 对齐线清除
689
- this.render.attractTool.alignLinesClear();
690
- // 重绘
691
- this.render.redraw([
692
- Draws.LinkDraw.name,
693
- Draws.RulerDraw.name,
694
- Draws.PreviewDraw.name
695
- ]);
696
- });
697
- this.group.add(circle);
698
- }
699
- // 拐点(已拐)
700
- for (let i = 1; i < linkPoints.length - 1; i++) {
701
- const circle = new Konva.Circle({
702
- name: 'link-manual-point',
703
- id: nanoid(),
704
- pairId: pair.id,
705
- x: linkPoints[i][0],
706
- y: linkPoints[i][1],
707
- radius: this.render.toStageValue(this.render.bgSize / 2),
708
- stroke: 'rgba(0,100,0,0.2)',
709
- strokeWidth: this.render.toStageValue(1),
710
- linkManualIndex: i // 当前拐点位置
711
- });
712
- // hover 效果
713
- circle.on('mouseenter', () => {
714
- circle.stroke('rgba(0,100,0,1)');
715
- document.body.style.cursor = 'pointer';
716
- });
717
- circle.on('mouseleave', () => {
718
- if (!circle.attrs.dragStart) {
719
- circle.stroke('rgba(0,100,0,0.1)');
720
- document.body.style.cursor = 'default';
721
- }
722
- });
723
- // 拐点操作
724
- circle.on('mousedown', () => {
725
- const pos = circle.getAbsolutePosition();
726
- // 记录操作开始状态
727
- circle.setAttrs({
728
- dragStartX: pos.x,
729
- dragStartY: pos.y,
730
- dragStart: true
731
- });
732
- // 标记状态 - 正在操作拐点
733
- this.state.linkManualing = true;
734
- });
735
- this.render.stage.on('mousemove', () => {
736
- if (circle.attrs.dragStart) {
737
- // 正在操作
738
- const pos = this.render.stage.getPointerPosition();
739
- if (pos) {
740
- // 磁贴
741
- const { pos: transformerPos } = this.render.attractTool.attractPoint(pos);
742
- // 移动拐点
743
- circle.setAbsolutePosition(transformerPos);
744
- // 正在拖动效果
745
- const tempPoints = [...linkPoints];
746
- tempPoints[circle.attrs.linkManualIndex] = [
747
- this.render.toStageValue(transformerPos.x - stageState.x),
748
- this.render.toStageValue(transformerPos.y - stageState.y)
749
- ];
750
- manualingLine.points(tempPoints.flat());
751
- }
752
- }
753
- });
754
- circle.on('mouseup', () => {
755
- const pos = circle.getAbsolutePosition();
756
- if (
757
- Math.abs(pos.x - circle.attrs.dragStartX) > this.option.size ||
758
- Math.abs(pos.y - circle.attrs.dragStartY) > this.option.size
759
- ) {
760
- // 操作移动距离达到阈值
761
- const stageState = this.render.getStageState();
762
- // 记录(更新)拐点
763
- manualPoints[circle.attrs.linkManualIndex - 1] = {
764
- x: this.render.toStageValue(pos.x - stageState.x),
765
- y: this.render.toStageValue(pos.y - stageState.y)
766
- };
767
- manualPointsMap[pair.id] = manualPoints;
768
- fromGroup.setAttr('manualPointsMap', manualPointsMap);
769
- }
770
- // 操作结束
771
- circle.setAttrs({ dragStart: false });
772
- // state 操作结束
773
- this.state.linkManualing = false;
774
- // 销毁
775
- circle.destroy();
776
- manualingLine.destroy();
777
- // 更新历史
778
- this.render.updateHistory();
779
- // 对齐线清除
780
- this.render.attractTool.alignLinesClear();
781
- // 重绘
782
- this.render.redraw([
783
- Draws.LinkDraw.name,
784
- Draws.RulerDraw.name,
785
- Draws.PreviewDraw.name
786
- ]);
787
- })
788
- this.group.add(circle);
789
- }
790
- }
791
- }
792
- } else if (pair.linkType === "bezier") {
793
- if (fromGroup && toGroup && fromPoint && toPoint) {
794
- const fromAnchor = fromGroup.findOne(`#${fromPoint.id}`);
795
- const toAnchor = toGroup.findOne(`#${toPoint.id}`);
796
- // 锚点信息
797
- const fromAnchorPos = this.getAnchorPos(fromAnchor);
798
- const toAnchorPos = this.getAnchorPos(toAnchor);
799
- // 拐点(已拐)记录
800
- const manualPointsMap: ManualPointsMap = fromGroup.getAttr('manualPointsMap') ?? ({} as ManualPointsMap);
801
- const manualPoints = manualPointsMap[pair.id] ?? ([] as ManualPoint[]);
802
- // 连接点 + 拐点
803
- const linkPoints = [
804
- [this.render.toStageValue(fromAnchorPos.x), this.render.toStageValue(fromAnchorPos.y)],
805
- ...manualPoints.map((o) => [o.x, o.y]),
806
- [this.render.toStageValue(toAnchorPos.x), this.render.toStageValue(toAnchorPos.y)]
807
- ];
808
- // 连接线
809
- const linkLine = new Konva.Arrow({
810
- name: 'link-line',
811
- // 用于删除连接线
812
- groupId: fromGroup.id(),
813
- pointId: fromPoint.id,
814
- pairId: pair.id,
815
- linkType: pair.linkType,
816
- points: linkPoints.flat(),
817
- pointerAtBeginning: false,
818
- pointerAtEnding: false,
819
- sceneFunc: BezierSceneFunc
820
- });
821
- linkLine.stroke(this.render.getLinkSettings(linkLine).stroke);
822
- linkLine.strokeWidth(this.render.getLinkSettings(linkLine).strokeWidth);
823
- linkLine.hitStrokeWidth(Math.max(this.render.getLinkSettings().strokeWidth, 10));
824
- linkLine.dash(this.render.linkTool.linkCurrent?.attrs.pairId === pair.id ? [1, 1] : []);
825
- linkLine.fill(this.render.getLinkSettings(linkLine).stroke);
826
- linkLine.pointerAtBeginning(this.render.getLinkSettings(linkLine).arrowStart);
827
- linkLine.pointerAtEnding(this.render.getLinkSettings(linkLine).arrowEnd);
828
- if (!this.render.config.readonly) {
829
- linkLine.on('pointerclick', () => this.render.linkTool.select(linkLine));
830
- linkLine.on('mouseenter', () => {
831
- linkLine.opacity(0.5);
832
- document.body.style.cursor = 'pointer';
833
- });
834
- linkLine.on('mouseleave', () => {
835
- linkLine.opacity(1);
836
- document.body.style.cursor = 'default';
837
- });
838
- }
839
- this.group.add(linkLine);
840
- if (!this.render.config.readonly) {
841
- // 正在拖动效果
842
- const manualingLine = new Konva.Arrow({
843
- name: 'manualing-line',
844
- stroke: '#ff0000',
845
- strokeWidth: 2,
846
- points: [],
847
- dash: [4, 4],
848
- pointerAtBeginning: false,
849
- pointerAtEnding: false,
850
- sceneFunc: BezierSceneFunc
851
- });
852
- this.group.add(manualingLine);
853
- // 拐点
854
- if (linkPoints.length <= 3) {
855
- // 拐点(待拐)
856
- for (let i = 0; i < linkPoints.length - 1; i++) {
857
- const circle = new Konva.Circle({
858
- name: 'link-manual-point',
859
- id: nanoid(),
860
- pairId: pair.id,
861
- x: (linkPoints[i][0] + linkPoints[i + 1][0]) / 2,
862
- y: (linkPoints[i][1] + linkPoints[i + 1][1]) / 2,
863
- radius: this.render.toStageValue(this.render.bgSize / 2),
864
- stroke: 'rgba(0,0,255,0.2)',
865
- strokeWidth: this.render.toStageValue(1),
866
- linkManualIndex: i // 当前拐点位置
867
- });
868
- // hover 效果
869
- circle.on('mouseenter', () => {
870
- circle.stroke('rgba(0,0,255,0.8)');
871
- document.body.style.cursor = 'pointer';
872
- });
873
- circle.on('mouseleave', () => {
874
- if (!circle.attrs.dragStart) {
875
- circle.stroke('rgba(0,0,255,0.1)');
876
- document.body.style.cursor = 'default';
877
- }
878
- });
879
- // 拐点操作
880
- circle.on('mousedown', () => {
881
- const pos = circle.getAbsolutePosition();
882
- // 记录操作开始状态
883
- circle.setAttrs({
884
- // 开始坐标
885
- dragStartX: pos.x,
886
- dragStartY: pos.y,
887
- // 正在操作
888
- dragStart: true
889
- });
890
- // 标记状态 - 正在操作拐点
891
- this.state.linkManualing = true;
892
- });
893
- this.render.stage.on('mousemove', () => {
894
- if (circle.attrs.dragStart) {
895
- // 正在操作
896
- const pos = this.render.stage.getPointerPosition();
897
- if (pos) {
898
- // 磁贴
899
- const { pos: transformerPos } = this.render.attractTool.attractPoint(pos);
900
- // 移动拐点
901
- circle.setAbsolutePosition(transformerPos);
902
- // 正在拖动效果
903
- const tempPoints = [...linkPoints];
904
- tempPoints.splice(circle.attrs.linkManualIndex + 1, 0, [
905
- this.render.toStageValue(transformerPos.x - stageState.x),
906
- this.render.toStageValue(transformerPos.y - stageState.y)
907
- ]);
908
- manualingLine.points(tempPoints.flat());
909
- }
910
- }
911
- });
912
- circle.on('mouseup', () => {
913
- const pos = circle.getAbsolutePosition();
914
- if (
915
- Math.abs(pos.x - circle.attrs.dragStartX) > this.option.size ||
916
- Math.abs(pos.y - circle.attrs.dragStartY) > this.option.size
917
- ) {
918
- // 操作移动距离达到阈值
919
- const stageState = this.render.getStageState();
920
- // 记录(插入)拐点
921
- manualPoints.splice(circle.attrs.linkManualIndex, 0, {
922
- x: this.render.toStageValue(pos.x - stageState.x),
923
- y: this.render.toStageValue(pos.y - stageState.y)
924
- });
925
- manualPointsMap[pair.id] = manualPoints;
926
- fromGroup.setAttr('manualPointsMap', manualPointsMap);
927
- }
928
- // 操作结束
929
- circle.setAttrs({ dragStart: false });
930
- // state 操作结束
931
- this.state.linkManualing = false;
932
- // 销毁
933
- circle.destroy();
934
- manualingLine.destroy();
935
- // 更新历史
936
- this.render.updateHistory();
937
- // 对齐线清除
938
- this.render.attractTool.alignLinesClear();
939
- // 重绘
940
- this.render.redraw([
941
- Draws.LinkDraw.name,
942
- Draws.RulerDraw.name,
943
- Draws.PreviewDraw.name
944
- ]);
945
- });
946
- this.group.add(circle);
947
- }
948
- }
949
- // 拐点(已拐)
950
- for (let i = 1; i < linkPoints.length - 1; i++) {
951
- const circle = new Konva.Circle({
952
- name: 'link-manual-point',
953
- id: nanoid(),
954
- pairId: pair.id,
955
- x: linkPoints[i][0],
956
- y: linkPoints[i][1],
957
- radius: this.render.toStageValue(this.render.bgSize / 2),
958
- stroke: 'rgba(0,100,0,0.2)',
959
- strokeWidth: this.render.toStageValue(1),
960
- linkManualIndex: i // 当前拐点位置
961
- });
962
- // hover 效果
963
- circle.on('mouseenter', () => {
964
- circle.stroke('rgba(0,100,0,1)');
965
- document.body.style.cursor = 'pointer';
966
- });
967
- circle.on('mouseleave', () => {
968
- if (!circle.attrs.dragStart) {
969
- circle.stroke('rgba(0,100,0,0.1)');
970
- document.body.style.cursor = 'default';
971
- }
972
- });
973
- // 拐点操作
974
- circle.on('mousedown', () => {
975
- const pos = circle.getAbsolutePosition();
976
- // 记录操作开始状态
977
- circle.setAttrs({
978
- dragStartX: pos.x,
979
- dragStartY: pos.y,
980
- dragStart: true
981
- });
982
- // 标记状态 - 正在操作拐点
983
- this.state.linkManualing = true;
984
- });
985
- this.render.stage.on('mousemove', () => {
986
- if (circle.attrs.dragStart) {
987
- // 正在操作
988
- const pos = this.render.stage.getPointerPosition();
989
- if (pos) {
990
- // 磁贴
991
- const { pos: transformerPos } = this.render.attractTool.attractPoint(pos);
992
- // 移动拐点
993
- circle.setAbsolutePosition(transformerPos);
994
- // 正在拖动效果
995
- const tempPoints = [...linkPoints]
996
- tempPoints[circle.attrs.linkManualIndex] = [
997
- this.render.toStageValue(transformerPos.x - stageState.x),
998
- this.render.toStageValue(transformerPos.y - stageState.y)
999
- ];
1000
- manualingLine.points(tempPoints.flat());
1001
- }
1002
- }
1003
- });
1004
- circle.on('mouseup', () => {
1005
- const pos = circle.getAbsolutePosition();
1006
- if (
1007
- Math.abs(pos.x - circle.attrs.dragStartX) > this.option.size ||
1008
- Math.abs(pos.y - circle.attrs.dragStartY) > this.option.size
1009
- ) {
1010
- // 操作移动距离达到阈值
1011
- const stageState = this.render.getStageState();
1012
- // 记录(更新)拐点
1013
- manualPoints[circle.attrs.linkManualIndex - 1] = {
1014
- x: this.render.toStageValue(pos.x - stageState.x),
1015
- y: this.render.toStageValue(pos.y - stageState.y)
1016
- };
1017
- manualPointsMap[pair.id] = manualPoints;
1018
- fromGroup.setAttr('manualPointsMap', manualPointsMap);
1019
- }
1020
- // 操作结束
1021
- circle.setAttrs({ dragStart: false });
1022
- // state 操作结束
1023
- this.state.linkManualing = false;
1024
- // 销毁
1025
- circle.destroy();
1026
- manualingLine.destroy();
1027
- // 更新历史
1028
- this.render.updateHistory();
1029
- // 对齐线清除
1030
- this.render.attractTool.alignLinesClear();
1031
- // 重绘
1032
- this.render.redraw([
1033
- Draws.LinkDraw.name,
1034
- Draws.RulerDraw.name,
1035
- Draws.PreviewDraw.name
1036
- ]);
1037
- });
1038
- this.group.add(circle);
1039
- }
1040
- }
1041
- }
1042
- } else if (pair.linkType === "straight") {
1043
- // 直线
1044
- if (fromGroup && toGroup && fromPoint && toPoint) {
1045
- const fromAnchor = fromGroup.findOne(`#${fromPoint.id}`);
1046
- const toAnchor = toGroup.findOne(`#${toPoint.id}`);
1047
- // 锚点信息
1048
- const fromAnchorPos = this.getAnchorPos(fromAnchor);
1049
- const toAnchorPos = this.getAnchorPos(toAnchor);
1050
- const linkLine = new Konva.Arrow({
1051
- name: 'link-line',
1052
- // 用于删除连接线
1053
- groupId: fromGroup.id(),
1054
- pointId: fromPoint.id,
1055
- pairId: pair.id,
1056
- linkType: pair.linkType,
1057
- points: [
1058
- [this.render.toStageValue(fromAnchorPos.x), this.render.toStageValue(fromAnchorPos.y)],
1059
- [this.render.toStageValue(toAnchorPos.x), this.render.toStageValue(toAnchorPos.y)]
1060
- ].flat(),
1061
- pointerAtBeginning: false,
1062
- pointerAtEnding: false
1063
- });
1064
- linkLine.stroke(this.render.getLinkSettings(linkLine).stroke);
1065
- linkLine.strokeWidth(this.render.getLinkSettings(linkLine).strokeWidth);
1066
- linkLine.hitStrokeWidth(Math.max(this.render.getLinkSettings().strokeWidth, 10));
1067
- linkLine.dash(this.render.linkTool.linkCurrent?.attrs.pairId === pair.id ? [1, 1] : []);
1068
- linkLine.fill(this.render.getLinkSettings(linkLine).stroke);
1069
- linkLine.pointerAtBeginning(this.render.getLinkSettings(linkLine).arrowStart);
1070
- linkLine.pointerAtEnding(this.render.getLinkSettings(linkLine).arrowEnd);
1071
-
1072
- if (!this.render.config.readonly) {
1073
- linkLine.on('pointerclick', () => this.render.linkTool.select(linkLine));
1074
- linkLine.on('mouseenter', () => {
1075
- linkLine.opacity(0.5);
1076
- document.body.style.cursor = 'pointer';
1077
- });
1078
- linkLine.on('mouseleave', () => {
1079
- linkLine.opacity(1);
1080
- document.body.style.cursor = 'default';
1081
- });
1082
- }
1083
- this.group.add(linkLine);
1084
- }
1085
- } else {
1086
- // 自动
1087
- // 最小区域
1088
- const fromGroupLinkArea = this.getGroupLinkArea(fromGroup);
1089
- const toGroupLinkArea = this.getGroupLinkArea(toGroup);
1090
- // 两区域的最短距离
1091
- const groupDistance = this.getGroupPairDistance(fromGroupLinkArea, toGroupLinkArea);
1092
- // 不可通过区域
1093
- const fromGroupForbiddenArea = this.getGroupForbiddenArea(fromGroupLinkArea, groupDistance - 2);
1094
- const toGroupForbiddenArea = this.getGroupForbiddenArea(toGroupLinkArea, groupDistance - 2);
1095
- // 两区域扩展
1096
- const groupForbiddenArea = this.getGroupPairArea(fromGroupForbiddenArea, toGroupForbiddenArea);
1097
- // 连线通过区域
1098
- const groupAccessArea = this.getGroupPairArea(this.getGroupAccessArea(fromGroupForbiddenArea, groupDistance), this.getGroupAccessArea(toGroupForbiddenArea, groupDistance));
1099
- if (fromGroup && toGroup && fromPoint && toPoint) {
1100
- const fromAnchor = fromGroup.findOne(`#${fromPoint.id}`);
1101
- const toAnchor = toGroup.findOne(`#${toPoint.id}`);
1102
- // 锚点信息
1103
- const fromAnchorPos = this.getAnchorPos(fromAnchor);
1104
- const toAnchorPos = this.getAnchorPos(toAnchor);
1105
- if (fromAnchor && toAnchor) {
1106
- // 连接出入口
1107
- const fromEntry: Konva.Vector2d = this.getEntry(fromAnchor, fromGroupForbiddenArea, groupDistance);
1108
- const toEntry: Konva.Vector2d = this.getEntry(toAnchor, toGroupForbiddenArea, groupDistance);
1109
- type matrixPoint = { x: number, y: number, type?: 'from' | 'to' | 'from-entry' | 'to-entry' };
1110
- // 可能点
1111
- let matrixPoints: matrixPoint[] = [];
1112
- // 通过区域 四角
1113
- matrixPoints.push({ x: groupAccessArea.x1, y: groupAccessArea.y1 });
1114
- matrixPoints.push({ x: groupAccessArea.x2, y: groupAccessArea.y2 });
1115
- matrixPoints.push({ x: groupAccessArea.x1, y: groupAccessArea.y2 });
1116
- matrixPoints.push({ x: groupAccessArea.x2, y: groupAccessArea.y1 });
1117
- // 最小区域 四角
1118
- matrixPoints.push({ x: groupForbiddenArea.x1, y: groupForbiddenArea.y1 });
1119
- matrixPoints.push({ x: groupForbiddenArea.x2, y: groupForbiddenArea.y2 });
1120
- matrixPoints.push({ x: groupForbiddenArea.x1, y: groupForbiddenArea.y2 });
1121
- matrixPoints.push({ x: groupForbiddenArea.x2, y: groupForbiddenArea.y1 });
1122
- // 起点
1123
- matrixPoints.push({ ...fromAnchorPos, type: 'from' });
1124
- // 起点 出口
1125
- matrixPoints.push({ ...fromEntry, type: 'from-entry' });
1126
- // 终点
1127
- matrixPoints.push({ ...toAnchorPos, type: 'to' });
1128
- // 终点 入口
1129
- matrixPoints.push({ ...toEntry, type: 'to-entry' });
1130
- // 通过区域 中点
1131
- matrixPoints.push(this.getGroupPairCenter(fromGroupForbiddenArea, toGroupForbiddenArea));
1132
- // 去重
1133
- matrixPoints = matrixPoints.reduce(
1134
- (arr, item) => {
1135
- if (item.type === void 0) {
1136
- if (arr.findIndex((o) => o.x === item.x && o.y === item.y) < 0) {
1137
- arr.push(item);
1138
- }
1139
- } else {
1140
- const idx = arr.findIndex((o) => o.x === item.x && o.y === item.y)
1141
- if (idx > -1) {
1142
- arr.splice(idx, 1);
1143
- }
1144
- arr.push(item);
1145
- }
1146
- return arr;
1147
- },
1148
- [] as typeof matrixPoints
1149
- );
1150
- const columns = [
1151
- ...matrixPoints.map((o) => o.x),
1152
- // 增加列
1153
- fromGroupForbiddenArea.x1,
1154
- fromGroupForbiddenArea.x2,
1155
- toGroupForbiddenArea.x1,
1156
- toGroupForbiddenArea.x2
1157
- ].sort((a, b) => a - b);
1158
- // 去重
1159
- for (let x = columns.length - 1; x > 0; x--) {
1160
- if (columns[x] === columns[x - 1]) {
1161
- columns.splice(x, 1);
1162
- }
1163
- }
1164
- const rows = [
1165
- ...matrixPoints.map((o) => o.y),
1166
- // 增加行
1167
- fromGroupForbiddenArea.y1,
1168
- fromGroupForbiddenArea.y2,
1169
- toGroupForbiddenArea.y1,
1170
- toGroupForbiddenArea.y2
1171
- ].sort((a, b) => a - b);
1172
- // 去重
1173
- for (let y = rows.length - 1; y > 0; y--) {
1174
- if (rows[y] === rows[y - 1]) {
1175
- rows.splice(y, 1);
1176
- }
1177
- }
1178
- // 屏蔽区域(序号)
1179
- const columnFromStart = columns.findIndex((o) => o === fromGroupForbiddenArea.x1);
1180
- const columnFromEnd = columns.findIndex((o) => o === fromGroupForbiddenArea.x2);
1181
- const rowFromStart = rows.findIndex((o) => o === fromGroupForbiddenArea.y1);
1182
- const rowFromEnd = rows.findIndex((o) => o === fromGroupForbiddenArea.y2);
1183
- const columnToStart = columns.findIndex((o) => o === toGroupForbiddenArea.x1);
1184
- const columnToEnd = columns.findIndex((o) => o === toGroupForbiddenArea.x2);
1185
- const rowToStart = rows.findIndex((o) => o === toGroupForbiddenArea.y1);
1186
- const rowToEnd = rows.findIndex((o) => o === toGroupForbiddenArea.y2);
1187
- // 算法矩阵起点、终点
1188
- let matrixStart: Konva.Vector2d | null = null;
1189
- let matrixEnd: Konva.Vector2d | null = null;
1190
- // 算法地图矩阵
1191
- const matrix: Array<number[]> = [];
1192
- for (let y = 0; y < rows.length; y++) {
1193
- // 新增行
1194
- if (matrix[y] === void 0) {
1195
- matrix[y] = [];
1196
- }
1197
- for (let x = 0; x < columns.length; x++) {
1198
- // 不可通过区域
1199
- if (
1200
- x >= columnFromStart &&
1201
- x <= columnFromEnd &&
1202
- y >= rowFromStart &&
1203
- y <= rowFromEnd
1204
- ) {
1205
- matrix[y][x] = 2;
1206
- } else if (
1207
- x >= columnToStart &&
1208
- x <= columnToEnd &&
1209
- y >= rowToStart &&
1210
- y <= rowToEnd
1211
- ) {
1212
- matrix[y][x] = 2;
1213
- } else {
1214
- // 可通过区域
1215
- matrix[y][x] = 0;
1216
- }
1217
- // 出口、入口 -> 算法 起点、终点
1218
- if (columns[x] === fromEntry.x && rows[y] === fromEntry.y) {
1219
- matrix[y][x] = 1;
1220
- matrixStart = { x, y };
1221
- }
1222
- if (columns[x] === toEntry.x && rows[y] === toEntry.y) {
1223
- matrix[y][x] = 1;
1224
- matrixEnd = { x, y };
1225
- }
1226
- // 没有定义方向(给于十字可通过区域)
1227
- // 如,从:
1228
- // 1 1 1
1229
- // 1 0 1
1230
- // 1 1 1
1231
- // 变成:
1232
- // 1 0 1
1233
- // 0 0 0
1234
- // 1 0 1
1235
- if (!fromAnchor.attrs.direction) {
1236
- if (columns[x] === fromEntry.x || rows[y] === fromEntry.y) {
1237
- if (
1238
- x >= columnFromStart &&
1239
- x <= columnFromEnd &&
1240
- y >= rowFromStart &&
1241
- y <= rowFromEnd
1242
- ) {
1243
- matrix[y][x] = 1;
1244
- }
1245
- }
1246
- }
1247
- if (!toAnchor.attrs.direction) {
1248
- if (columns[x] === toEntry.x || rows[y] === toEntry.y) {
1249
- if (
1250
- x >= columnToStart &&
1251
- x <= columnToEnd &&
1252
- y >= rowToStart &&
1253
- y <= rowToEnd
1254
- ) {
1255
- matrix[y][x] = 1;
1256
- }
1257
- }
1258
- }
1259
- }
1260
- }
1261
-
1262
- if (matrixStart && matrixEnd) {
1263
- const way = aStar({ from: matrixStart, to: matrixEnd, matrix, maxCost: 2 });
1264
- const linkLine = new Konva.Arrow({
1265
- name: 'link-line',
1266
- // 用于删除连接线
1267
- groupId: fromGroup.id(),
1268
- pointId: fromPoint.id,
1269
- pairId: pair.id,
1270
- linkType: pair.linkType, // 记录 连接线 类型
1271
- points: [
1272
- [this.render.toStageValue(fromAnchorPos.x), this.render.toStageValue(fromAnchorPos.y)], // 补充 起点
1273
- ...way.map((o) => [this.render.toStageValue(columns[o.x]), this.render.toStageValue(rows[o.y])]),
1274
- [this.render.toStageValue(toAnchorPos.x), this.render.toStageValue(toAnchorPos.y)] // 补充 终点
1275
- ].flat(),
1276
- pointerAtBeginning: false,
1277
- pointerAtEnding: false
1278
- });
1279
- linkLine.stroke(this.render.getLinkSettings(linkLine).stroke);
1280
- linkLine.strokeWidth(this.render.getLinkSettings(linkLine).strokeWidth);
1281
- linkLine.hitStrokeWidth(Math.max(this.render.getLinkSettings().strokeWidth, 10));
1282
- linkLine.dash(this.render.linkTool.linkCurrent?.attrs.pairId === pair.id ? [1, 1] : []);
1283
- linkLine.fill(this.render.getLinkSettings(linkLine).stroke);
1284
- linkLine.pointerAtBeginning(this.render.getLinkSettings(linkLine).arrowStart);
1285
- linkLine.pointerAtEnding(this.render.getLinkSettings(linkLine).arrowEnd);
1286
- if (!this.render.config.readonly) {
1287
- linkLine.on('pointerclick', () => this.render.linkTool.select(linkLine));
1288
- linkLine.on('mouseenter', () => {
1289
- linkLine.opacity(0.5);
1290
- document.body.style.cursor = 'pointer';
1291
- });
1292
- linkLine.on('mouseleave', () => {
1293
- linkLine.opacity(1);
1294
- document.body.style.cursor = 'default';
1295
- });
1296
- }
1297
- this.group.add(linkLine);
1298
- }
1299
- }
1300
- }
1301
- }
1302
- }
1303
- }
1304
-
1305
- if (!this.render.config.readonly) {
1306
- // 连接点
1307
- for (const point of points) {
1308
- const group = groups.find((o) => o.id() === point.groupId);
1309
- // 选择中
1310
- if (group && !group.getAttr('selected')) {
1311
- const anchor = this.render.layer.findOne(`#${point.id}`);
1312
- if (anchor) {
1313
- const circle = new Konva.Circle({
1314
- name: 'link-point',
1315
- id: point.id,
1316
- groupId: group.id(),
1317
- x: this.render.toStageValue(anchor.absolutePosition().x - stageState.x),
1318
- y: this.render.toStageValue(anchor.absolutePosition().y - stageState.y),
1319
- radius: this.render.toStageValue(this.option.size),
1320
- stroke: 'rgba(255,0,0,0.2)',
1321
- strokeWidth: this.render.toStageValue(1),
1322
- // 调整中,不显示连接点
1323
- opacity: point.visible && !(this.render.draws[Draws.GraphDraw.name] as Draws.GraphDraw).state.adjusting ? 1 : 0
1324
- });
1325
- // hover 效果
1326
- circle.on('mouseenter', () => {
1327
- circle.stroke('rgba(255,0,0,0.5)');
1328
- circle.opacity(1);
1329
- document.body.style.cursor = 'pointer';
1330
- });
1331
- circle.on('mouseleave', () => {
1332
- circle.stroke('rgba(255,0,0,0.2)');
1333
- circle.opacity(0);
1334
- document.body.style.cursor = 'default';
1335
- });
1336
- circle.on('mousedown', () => {
1337
- this.render.selectionTool.selectingClear();
1338
- this.render.linkTool.selectingClear();
1339
- const pos = this.render.stage.getPointerPosition();
1340
- if (pos) {
1341
- // 临时 连接线 画
1342
- this.state.linkingLine = {
1343
- group: group,
1344
- circle: circle,
1345
- line: new Konva.Line({
1346
- name: 'linking-line',
1347
- points: [
1348
- [circle.x(), circle.y()],
1349
- [
1350
- this.render.toStageValue(pos.x - stageState.x),
1351
- this.render.toStageValue(pos.y - stageState.y)
1352
- ]
1353
- ].flat(),
1354
- stroke: 'blue',
1355
- strokeWidth: 1
1356
- })
1357
- };
1358
- this.layer.add(this.state.linkingLine.line);
1359
- }
1360
- });
1361
- circle.on('mouseup', () => {
1362
- if (this.state.linkingLine) {
1363
- const line = this.state.linkingLine;
1364
- // 不同连接点
1365
- if (line.circle.id() !== circle.id()) {
1366
- const toGroup = groups.find((o) => o.id() === circle.getAttr('groupId'));
1367
- if (toGroup) {
1368
- const fromPoint = points.find((o) => o.id === line.circle.id());
1369
- if (fromPoint) {
1370
- const toPoint = points.find((o) => o.id === line.circle.id());
1371
- if (toPoint) {
1372
- if (Array.isArray(fromPoint.pairs)) {
1373
- fromPoint.pairs = [
1374
- ...fromPoint.pairs,
1375
- {
1376
- id: nanoid(),
1377
- from: {
1378
- groupId: line.group.id(),
1379
- pointId: line.circle.id()
1380
- },
1381
- to: {
1382
- groupId: circle.getAttr('groupId'),
1383
- pointId: circle.id()
1384
- },
1385
- linkType: this.state.linkType // 记录 连接线 类型
1386
- }
1387
- ];
1388
- }
1389
- // 更新历史
1390
- this.render.updateHistory();
1391
- // 对齐线清除
1392
- this.render.attractTool.alignLinesClear();
1393
- // 重绘
1394
- this.render.redraw([
1395
- Draws.LinkDraw.name,
1396
- Draws.RulerDraw.name,
1397
- Draws.PreviewDraw.name
1398
- ]);
1399
- }
1400
- }
1401
- }
1402
- }
1403
- // 临时 连接线 移除
1404
- this.state.linkingLine?.line.destroy();
1405
- this.state.linkingLine = null;
1406
- }
1407
- });
1408
- this.group.add(circle);
1409
- }
1410
- }
1411
- }
1412
- }
1413
- }
1414
- }
1
+ import Konva from 'konva';
2
+ import { LinkType, BaseDraw, Draw, Render, LinkDrawPoint, LinkDrawPair, ManualPointsMap, ManualPoint } from '../types';
3
+ import * as Draws from '../draws';
4
+ import { nanoid } from 'nanoid';
5
+ import aStar from '../utils/a-star';
6
+ import { BezierSceneFunc } from '../utils/bezier-scene-func';
7
+
8
+ // 绘制连线
9
+
10
+ export interface LinkDrawOption {
11
+ size: number
12
+ }
13
+
14
+ // 连接线(临时)
15
+ export interface LinkDrawState {
16
+ linkingLine: {
17
+ group: Konva.Group;
18
+ circle: Konva.Circle;
19
+ line: Konva.Line
20
+ } | null;
21
+ linkType: LinkType; // 连接线类型
22
+ linkManualing: boolean // 是否 正在操作拐点
23
+ }
24
+
25
+ type Area = {
26
+ x1: number;
27
+ y1: number;
28
+ x2: number;
29
+ y2: number;
30
+ }
31
+
32
+ export class LinkDraw extends BaseDraw implements Draw {
33
+ static readonly NAME = 'LinkDraw';
34
+ option: LinkDrawOption;
35
+
36
+ state: LinkDrawState = {
37
+ linkingLine: null,
38
+ linkType: "curve",
39
+ linkManualing: false
40
+ }
41
+
42
+ constructor(render: Render, layer: Konva.Layer, option: LinkDrawOption) {
43
+ super(render, layer);
44
+ this.option = option;
45
+ this.group.name(LinkDraw.NAME);
46
+ }
47
+
48
+ // 元素(连接点们)最小区域(绝对值)
49
+ getGroupLinkArea(group?: Konva.Group): Area {
50
+ let area: Area = { x1: 0, y1: 0, x2: 0, y2: 0 };
51
+ if (group) {
52
+ const stageState = this.render.getStageState(); // stage 状态
53
+ const anchors = group.find('.link-anchor');
54
+ const positions = anchors.map((o) => o.absolutePosition());
55
+ area = {
56
+ x1: Math.min(...positions.map((o) => o.x)) - stageState.x,
57
+ y1: Math.min(...positions.map((o) => o.y)) - stageState.y,
58
+ x2: Math.max(...positions.map((o) => o.x)) - stageState.x,
59
+ y2: Math.max(...positions.map((o) => o.y)) - stageState.y
60
+ };
61
+ }
62
+ return area;
63
+ }
64
+
65
+ // 连线不可通过区域
66
+ getGroupForbiddenArea(groupArea: Area, gap: number): Area {
67
+ const area: Area = {
68
+ x1: groupArea.x1 - gap,
69
+ y1: groupArea.y1 - gap,
70
+ x2: groupArea.x2 + gap,
71
+ y2: groupArea.y2 + gap
72
+ };
73
+ return area;
74
+ }
75
+
76
+ // 连线通过区域
77
+ getGroupAccessArea(groupArea: Area, gap: number): Area {
78
+ const area: Area = {
79
+ x1: groupArea.x1 - gap,
80
+ y1: groupArea.y1 - gap,
81
+ x2: groupArea.x2 + gap,
82
+ y2: groupArea.y2 + gap
83
+ };
84
+ return area;
85
+ }
86
+
87
+ // 两区域扩展
88
+ getGroupPairArea(groupArea1: Area, groupArea2: Area): Area {
89
+ const area: Area = {
90
+ x1: Math.min(groupArea1.x1, groupArea2.x1),
91
+ y1: Math.min(groupArea1.y1, groupArea2.y1),
92
+ x2: Math.max(groupArea1.x2, groupArea2.x2),
93
+ y2: Math.max(groupArea1.y2, groupArea2.y2)
94
+ };
95
+ return area;
96
+ }
97
+
98
+ // 两区域最短距离
99
+ getGroupPairDistance(groupArea1: Area, groupArea2: Area): number {
100
+ const xs = [groupArea1.x1, groupArea1.x2, groupArea2.x1, groupArea2.x2];
101
+ const maxX = Math.max(...xs);
102
+ const minX = Math.min(...xs);
103
+ const dx = maxX - minX - (groupArea1.x2 - groupArea1.x1 + (groupArea2.x2 - groupArea2.x1));
104
+ const ys = [groupArea1.y1, groupArea1.y2, groupArea2.y1, groupArea2.y2];
105
+ const maxY = Math.max(...ys);
106
+ const minY = Math.min(...ys);
107
+ const dy = maxY - minY - (groupArea1.y2 - groupArea1.y1 + (groupArea2.y2 - groupArea2.y1));
108
+ return this.render.toBoardValue(Math.min(this.render.bgSize * 0.5, Math.max(dx < 6 ? 6 : dx, dy < 6 ? 6 : dy) * 0.5));
109
+ }
110
+
111
+ // 两区域空隙中点
112
+ getGroupPairCenter(groupArea1: Area, groupArea2: Area): Konva.Vector2d {
113
+ return { x: (groupArea2.x1 + groupArea1.x2) * 0.5, y: (groupArea2.y1 + groupArea1.y2) * 0.5 };
114
+ }
115
+
116
+ // 连接出入口
117
+ getEntry(anchor: Konva.Node, groupForbiddenArea: Area, gap: number): Konva.Vector2d {
118
+ const stageState = this.render.getStageState();
119
+ const fromPos = anchor.absolutePosition();
120
+ // 默认为 起点/终点 位置(无 direction 时的值)
121
+ let x = fromPos.x - stageState.x;
122
+ let y = fromPos.y - stageState.y;
123
+ const direction = anchor.attrs.direction;
124
+ // 定义了 direction 的时候
125
+ if (direction) {
126
+ // 取整 连接点 锚点 旋转角度(保留 1 位小数点)
127
+ const rotate = Math.round(anchor.getAbsoluteRotation() * 10) / 10;
128
+ if (rotate === -45) {
129
+ if (direction === 'top') {
130
+ x = groupForbiddenArea.x1;
131
+ y = groupForbiddenArea.y1;
132
+ } else if (direction === 'bottom') {
133
+ x = groupForbiddenArea.x2;
134
+ y = groupForbiddenArea.y2;
135
+ } else if (direction === 'left') {
136
+ x = groupForbiddenArea.x1;
137
+ y = groupForbiddenArea.y2;
138
+ } else if (direction === 'right') {
139
+ x = groupForbiddenArea.x2;
140
+ y = groupForbiddenArea.y1;
141
+ }
142
+ } else if (rotate === 45) {
143
+ if (direction === 'top') {
144
+ x = groupForbiddenArea.x2;
145
+ y = groupForbiddenArea.y1;
146
+ } else if (direction === 'bottom') {
147
+ x = groupForbiddenArea.x1;
148
+ y = groupForbiddenArea.y2;
149
+ } else if (direction === 'left') {
150
+ x = groupForbiddenArea.x1;
151
+ y = groupForbiddenArea.y1;
152
+ } else if (direction === 'right') {
153
+ x = groupForbiddenArea.x2;
154
+ y = groupForbiddenArea.y2;
155
+ }
156
+ } else if (rotate === 135) {
157
+ if (direction === 'top') {
158
+ x = groupForbiddenArea.x2;
159
+ y = groupForbiddenArea.y2;
160
+ } else if (direction === 'bottom') {
161
+ x = groupForbiddenArea.x1;
162
+ y = groupForbiddenArea.y1;
163
+ } else if (direction === 'left') {
164
+ x = groupForbiddenArea.x2;
165
+ y = groupForbiddenArea.y1;
166
+ } else if (direction === 'right') {
167
+ x = groupForbiddenArea.x1;
168
+ y = groupForbiddenArea.y2;
169
+ }
170
+ } else if (rotate === -135) {
171
+ if (direction === 'top') {
172
+ x = groupForbiddenArea.x1;
173
+ y = groupForbiddenArea.y2;
174
+ } else if (direction === 'bottom') {
175
+ x = groupForbiddenArea.x2;
176
+ y = groupForbiddenArea.y1;
177
+ } else if (direction === 'left') {
178
+ x = groupForbiddenArea.x2;
179
+ y = groupForbiddenArea.y2;
180
+ } else if (direction === 'right') {
181
+ x = groupForbiddenArea.x1;
182
+ y = groupForbiddenArea.y1;
183
+ }
184
+ } else if (rotate > -45 && rotate < 45) {
185
+ const offset = gap * Math.tan((rotate * Math.PI) / 180);
186
+ if (direction === 'top') {
187
+ x = fromPos.x - stageState.x + offset;
188
+ y = groupForbiddenArea.y1;
189
+ } else if (direction === 'bottom') {
190
+ x = fromPos.x - stageState.x - offset;
191
+ y = groupForbiddenArea.y2;
192
+ } else if (direction === 'left') {
193
+ x = groupForbiddenArea.x1;
194
+ y = fromPos.y - stageState.y - offset;
195
+ } else if (direction === 'right') {
196
+ x = groupForbiddenArea.x2;
197
+ y = fromPos.y - stageState.y + offset;
198
+ }
199
+ } else if (rotate > 45 && rotate < 135) {
200
+ const offset = gap * Math.atan(((90 - rotate) * Math.PI) / 180);
201
+ if (direction === 'top') {
202
+ x = groupForbiddenArea.x2;
203
+ y = fromPos.y - stageState.y - offset;
204
+ } else if (direction === 'bottom') {
205
+ x = groupForbiddenArea.x1;
206
+ y = fromPos.y - stageState.y + offset;
207
+ } else if (direction === 'left') {
208
+ x = fromPos.x - stageState.x - offset;
209
+ y = groupForbiddenArea.y1;
210
+ } else if (direction === 'right') {
211
+ x = fromPos.x - stageState.x + offset;
212
+ y = groupForbiddenArea.y2;
213
+ }
214
+ } else if ((rotate > 135 && rotate <= 180) || (rotate >= -180 && rotate < -135)) {
215
+ const offset = gap * Math.tan((rotate * Math.PI) / 180);
216
+ if (direction === 'top') {
217
+ x = fromPos.x - stageState.x - offset;
218
+ y = groupForbiddenArea.y2;
219
+ } else if (direction === 'bottom') {
220
+ x = fromPos.x - stageState.x + offset;
221
+ y = groupForbiddenArea.y1;
222
+ } else if (direction === 'left') {
223
+ x = groupForbiddenArea.x2;
224
+ y = fromPos.y - stageState.y + offset;
225
+ } else if (direction === 'right') {
226
+ x = groupForbiddenArea.x1;
227
+ y = fromPos.y - stageState.y - offset;
228
+ }
229
+ } else if (rotate > -135 && rotate < -45) {
230
+ const offset = gap * Math.atan(((90 + rotate) * Math.PI) / 180);
231
+ if (direction === 'top') {
232
+ x = groupForbiddenArea.x1;
233
+ y = fromPos.y - stageState.y - offset;
234
+ } else if (direction === 'bottom') {
235
+ x = groupForbiddenArea.x2;
236
+ y = fromPos.y - stageState.y + offset;
237
+ } else if (direction === 'left') {
238
+ x = fromPos.x - stageState.x - offset;
239
+ y = groupForbiddenArea.y2;
240
+ } else if (direction === 'right') {
241
+ x = fromPos.x - stageState.x + offset;
242
+ y = groupForbiddenArea.y1;
243
+ }
244
+ }
245
+ }
246
+ return { x, y } as Konva.Vector2d;
247
+ }
248
+
249
+ // 连接点信息
250
+ getAnchorPos(anchor?: Konva.Node): Konva.Vector2d {
251
+ const stageState = this.render.getStageState();
252
+ return anchor ? { x: anchor.absolutePosition().x - stageState.x, y: anchor.absolutePosition().y - stageState.y } : { x: 0, y: 0 };
253
+ }
254
+
255
+ /**
256
+ * 修改当前连接线类型
257
+ * @param linkType LinkType
258
+ */
259
+ changeLinkType(linkType: LinkType) {
260
+ this.state.linkType = linkType;
261
+ this.render.emit('link-type-change', this.state.linkType);
262
+ }
263
+
264
+ override draw() {
265
+ this.clear();
266
+ const stageState = this.render.getStageState();
267
+
268
+ // 所有层级的素材
269
+ const groups = [
270
+ ...(this.render.layer.find('.asset') as Konva.Group[]),
271
+ ...(this.render.layer.find('.sub-asset') as Konva.Group[])
272
+ ];
273
+ const points = groups.reduce((ps, group) => ps.concat(Array.isArray(group.getAttr('points')) ? group.getAttr('points') : []), [] as LinkDrawPoint[]);
274
+ const pairs = points.reduce((ps, point) => ps.concat(point.pairs ? point.pairs.filter((o) => !o.disabled) : []), [] as LinkDrawPair[]);
275
+
276
+ // 连接线
277
+ for (const pair of pairs) {
278
+ // 多层素材,需要排除内部 pair
279
+ // pair 也不能为 disabled
280
+ if (pair.from.groupId !== pair.to.groupId && !pair.disabled) {
281
+ const fromGroup = groups.find((o) => o.id() === pair.from.groupId);
282
+ const fromPoint = points.find((o) => o.id === pair.from.pointId);
283
+ const toGroup = groups.find((o) => o.id() === pair.to.groupId);
284
+ const toPoint = points.find((o) => o.id === pair.to.pointId);
285
+ if (pair.linkType === "manual") {
286
+ // 折线
287
+ if (fromGroup && toGroup && fromPoint && toPoint) {
288
+ const fromAnchor = fromGroup.findOne(`#${fromPoint.id}`);
289
+ const toAnchor = toGroup.findOne(`#${toPoint.id}`);
290
+ // 锚点信息
291
+ const fromAnchorPos = this.getAnchorPos(fromAnchor);
292
+ const toAnchorPos = this.getAnchorPos(toAnchor);
293
+ // 拐点(已拐)记录
294
+ const manualPointsMap: ManualPointsMap = fromGroup.getAttr('manualPointsMap') ?? ({} as ManualPointsMap);
295
+ const manualPoints = manualPointsMap[pair.id] ?? ([] as ManualPoint[]);
296
+ // 连接点 + 拐点
297
+ const linkPoints = [
298
+ [this.render.toStageValue(fromAnchorPos.x), this.render.toStageValue(fromAnchorPos.y)],
299
+ ...manualPoints.map((o) => [o.x, o.y]),
300
+ [this.render.toStageValue(toAnchorPos.x), this.render.toStageValue(toAnchorPos.y)]
301
+ ];
302
+
303
+ // 连接线
304
+ const linkLine = new Konva.Arrow({
305
+ name: 'link-line',
306
+ // 用于删除连接线
307
+ groupId: fromGroup.id(),
308
+ pointId: fromPoint.id,
309
+ pairId: pair.id,
310
+ linkType: pair.linkType,
311
+ points: linkPoints.flat(),
312
+ pointerAtBeginning: false,
313
+ pointerAtEnding: false
314
+ });
315
+ linkLine.stroke(this.render.getLinkSettings(linkLine).stroke);
316
+ linkLine.strokeWidth(this.render.getLinkSettings(linkLine).strokeWidth);
317
+ linkLine.hitStrokeWidth(Math.max(this.render.getLinkSettings().strokeWidth, 10));
318
+ linkLine.dash(this.render.linkTool.linkCurrent?.attrs.pairId === pair.id ? [1, 1] : []);
319
+ linkLine.fill(this.render.getLinkSettings(linkLine).stroke);
320
+ linkLine.pointerAtBeginning(this.render.getLinkSettings(linkLine).arrowStart);
321
+ linkLine.pointerAtEnding(this.render.getLinkSettings(linkLine).arrowEnd);
322
+ if (!this.render.config.readonly) {
323
+ linkLine.on('pointerclick', () => this.render.linkTool.select(linkLine));
324
+ linkLine.on('mouseenter', () => {
325
+ linkLine.opacity(0.5);
326
+ document.body.style.cursor = 'pointer';
327
+ });
328
+ linkLine.on('mouseleave', () => {
329
+ linkLine.opacity(1);
330
+ document.body.style.cursor = 'default';
331
+ });
332
+ }
333
+ this.group.add(linkLine);
334
+ if (!this.render.config.readonly) {
335
+ // 正在拖动效果
336
+ const manualingLine = new Konva.Line({
337
+ name: 'manualing-line',
338
+ stroke: '#ff0000',
339
+ strokeWidth: 2,
340
+ points: [],
341
+ dash: [4, 4]
342
+ });
343
+ this.group.add(manualingLine);
344
+ for (let i = 0; i < linkPoints.length - 1; i++) {
345
+ const circle = new Konva.Circle({
346
+ name: 'link-manual-point',
347
+ id: nanoid(),
348
+ pairId: pair.id,
349
+ x: (linkPoints[i][0] + linkPoints[i + 1][0]) / 2,
350
+ y: (linkPoints[i][1] + linkPoints[i + 1][1]) / 2,
351
+ radius: this.render.toStageValue(this.render.bgSize / 2),
352
+ stroke: 'rgba(0,0,255,0.2)',
353
+ strokeWidth: this.render.toStageValue(1),
354
+ linkManualIndex: i // 当前拐点位置
355
+ });
356
+ // hover 效果
357
+ circle.on('mouseenter', () => {
358
+ circle.stroke('rgba(0,0,255,0.8)');
359
+ document.body.style.cursor = 'pointer';
360
+ });
361
+ circle.on('mouseleave', () => {
362
+ if (!circle.attrs.dragStart) {
363
+ circle.stroke('rgba(0,0,255,0.1)');
364
+ document.body.style.cursor = 'default';
365
+ }
366
+ });
367
+
368
+ // 拐点操作
369
+ circle.on('mousedown', () => {
370
+ const pos = circle.getAbsolutePosition();
371
+ // 记录操作开始状态
372
+ circle.setAttrs({
373
+ // 开始坐标
374
+ dragStartX: pos.x,
375
+ dragStartY: pos.y,
376
+ // 正在操作
377
+ dragStart: true
378
+ });
379
+ // 标记状态 - 正在操作拐点
380
+ this.state.linkManualing = true;
381
+ });
382
+ this.render.stage.on('mousemove', () => {
383
+ if (circle.attrs.dragStart) {
384
+ // 正在操作
385
+ const pos = this.render.stage.getPointerPosition();
386
+ if (pos) {
387
+ // 磁贴
388
+ const { pos: transformerPos } = this.render.attractTool.attractPoint(pos);
389
+ // 移动拐点
390
+ circle.setAbsolutePosition(transformerPos);
391
+ // 正在拖动效果
392
+ const tempPoints = [...linkPoints];
393
+ tempPoints.splice(circle.attrs.linkManualIndex + 1, 0, [
394
+ this.render.toStageValue(transformerPos.x - stageState.x),
395
+ this.render.toStageValue(transformerPos.y - stageState.y)
396
+ ]);
397
+ manualingLine.points(tempPoints.flat());
398
+ }
399
+ }
400
+ });
401
+ circle.on('mouseup', () => {
402
+ const pos = circle.getAbsolutePosition();
403
+ if (
404
+ Math.abs(pos.x - circle.attrs.dragStartX) > this.option.size ||
405
+ Math.abs(pos.y - circle.attrs.dragStartY) > this.option.size
406
+ ) {
407
+ // 操作移动距离达到阈值
408
+ const stageState = this.render.getStageState();
409
+ // 记录(插入)拐点
410
+ manualPoints.splice(circle.attrs.linkManualIndex, 0, {
411
+ x: this.render.toStageValue(pos.x - stageState.x),
412
+ y: this.render.toStageValue(pos.y - stageState.y)
413
+ });
414
+ manualPointsMap[pair.id] = manualPoints;
415
+ fromGroup.setAttr('manualPointsMap', manualPointsMap);
416
+ }
417
+
418
+ // 操作结束
419
+ circle.setAttrs({ dragStart: false });
420
+
421
+ // state 操作结束
422
+ this.state.linkManualing = false;
423
+
424
+ // 销毁
425
+ circle.destroy();
426
+ manualingLine.destroy();
427
+
428
+ // 更新历史
429
+ this.render.updateHistory();
430
+
431
+ // 对齐线清除
432
+ this.render.attractTool.alignLinesClear();
433
+
434
+ // 重绘
435
+ this.render.redraw([
436
+ Draws.LinkDraw.NAME,
437
+ Draws.RulerDraw.NAME,
438
+ Draws.PreviewDraw.NAME
439
+ ]);
440
+ })
441
+
442
+ this.group.add(circle);
443
+ }
444
+
445
+ // 拐点(已拐)
446
+ for (let i = 1; i < linkPoints.length - 1; i++) {
447
+ const circle = new Konva.Circle({
448
+ name: 'link-manual-point',
449
+ id: nanoid(),
450
+ pairId: pair.id,
451
+ x: linkPoints[i][0],
452
+ y: linkPoints[i][1],
453
+ radius: this.render.toStageValue(this.render.bgSize / 2),
454
+ stroke: 'rgba(0,100,0,0.2)',
455
+ strokeWidth: this.render.toStageValue(1),
456
+ linkManualIndex: i // 当前拐点位置
457
+ });
458
+
459
+ // hover 效果
460
+ circle.on('mouseenter', () => {
461
+ circle.stroke('rgba(0,100,0,1)');
462
+ document.body.style.cursor = 'pointer';
463
+ });
464
+ circle.on('mouseleave', () => {
465
+ if (!circle.attrs.dragStart) {
466
+ circle.stroke('rgba(0,100,0,0.1)');
467
+ document.body.style.cursor = 'default';
468
+ }
469
+ });
470
+
471
+ // 拐点操作
472
+ circle.on('mousedown', () => {
473
+ const pos = circle.getAbsolutePosition();
474
+ // 记录操作开始状态
475
+ circle.setAttrs({
476
+ dragStartX: pos.x,
477
+ dragStartY: pos.y,
478
+ dragStart: true
479
+ });
480
+
481
+ // 标记状态 - 正在操作拐点
482
+ this.state.linkManualing = true;
483
+ })
484
+ this.render.stage.on('mousemove', () => {
485
+ if (circle.attrs.dragStart) {
486
+ // 正在操作
487
+ const pos = this.render.stage.getPointerPosition();
488
+ if (pos) {
489
+ // 磁贴
490
+ const { pos: transformerPos } = this.render.attractTool.attractPoint(pos);
491
+ // 移动拐点
492
+ circle.setAbsolutePosition(transformerPos);
493
+ // 正在拖动效果
494
+ const tempPoints = [...linkPoints];
495
+ tempPoints[circle.attrs.linkManualIndex] = [
496
+ this.render.toStageValue(transformerPos.x - stageState.x),
497
+ this.render.toStageValue(transformerPos.y - stageState.y)
498
+ ];
499
+ manualingLine.points(tempPoints.flat());
500
+ }
501
+ }
502
+ });
503
+ circle.on('mouseup', () => {
504
+ const pos = circle.getAbsolutePosition();
505
+ if (
506
+ Math.abs(pos.x - circle.attrs.dragStartX) > this.option.size ||
507
+ Math.abs(pos.y - circle.attrs.dragStartY) > this.option.size
508
+ ) {
509
+ // 操作移动距离达到阈值
510
+ const stageState = this.render.getStageState();
511
+ // 记录(更新)拐点
512
+ manualPoints[circle.attrs.linkManualIndex - 1] = {
513
+ x: this.render.toStageValue(pos.x - stageState.x),
514
+ y: this.render.toStageValue(pos.y - stageState.y)
515
+ };
516
+ manualPointsMap[pair.id] = manualPoints;
517
+ fromGroup.setAttr('manualPointsMap', manualPointsMap);
518
+ }
519
+ // 操作结束
520
+ circle.setAttrs({ dragStart: false });
521
+ // state 操作结束
522
+ this.state.linkManualing = false;
523
+ // 销毁
524
+ circle.destroy();
525
+ manualingLine.destroy();
526
+ // 更新历史
527
+ this.render.updateHistory();
528
+ // 对齐线清除
529
+ this.render.attractTool.alignLinesClear();
530
+ // 重绘
531
+ this.render.redraw([
532
+ Draws.LinkDraw.NAME,
533
+ Draws.RulerDraw.NAME,
534
+ Draws.PreviewDraw.NAME
535
+ ]);
536
+ })
537
+ this.group.add(circle);
538
+ }
539
+ }
540
+ }
541
+ } else if (pair.linkType === "curve") {
542
+ // 曲线
543
+ if (fromGroup && toGroup && fromPoint && toPoint) {
544
+ const fromAnchor = fromGroup.findOne(`#${fromPoint.id}`);
545
+ const toAnchor = toGroup.findOne(`#${toPoint.id}`);
546
+ // 锚点信息
547
+ const fromAnchorPos = this.getAnchorPos(fromAnchor);
548
+ const toAnchorPos = this.getAnchorPos(toAnchor);
549
+ // 拐点(已拐)记录
550
+ const manualPointsMap: ManualPointsMap = fromGroup.getAttr('manualPointsMap') ?? ({} as ManualPointsMap);
551
+ const manualPoints = manualPointsMap[pair.id] ?? ([] as ManualPoint[]);
552
+ // 连接点 + 拐点
553
+ const linkPoints = [
554
+ [
555
+ this.render.toStageValue(fromAnchorPos.x),
556
+ this.render.toStageValue(fromAnchorPos.y)
557
+ ],
558
+ ...manualPoints.map((o) => [o.x, o.y]),
559
+ [this.render.toStageValue(toAnchorPos.x), this.render.toStageValue(toAnchorPos.y)]
560
+ ];
561
+
562
+ // 连接线
563
+ const linkLine = new Konva.Arrow({
564
+ name: 'link-line',
565
+ // 用于删除连接线
566
+ groupId: fromGroup.id(),
567
+ pointId: fromPoint.id,
568
+ pairId: pair.id,
569
+ linkType: pair.linkType,
570
+ points: linkPoints.flat(),
571
+ pointerAtBeginning: false,
572
+ pointerAtEnding: false
573
+ });
574
+ linkLine.stroke(this.render.getLinkSettings(linkLine).stroke);
575
+ linkLine.strokeWidth(this.render.getLinkSettings(linkLine).strokeWidth);
576
+ linkLine.hitStrokeWidth(Math.max(this.render.getLinkSettings().strokeWidth, 10));
577
+ linkLine.dash(this.render.linkTool.linkCurrent?.attrs.pairId === pair.id ? [1, 1] : []);
578
+ linkLine.fill(this.render.getLinkSettings(linkLine).stroke);
579
+ linkLine.pointerAtBeginning(this.render.getLinkSettings(linkLine).arrowStart);
580
+ linkLine.pointerAtEnding(this.render.getLinkSettings(linkLine).arrowEnd);
581
+ linkLine.tension(this.render.getLinkSettings(linkLine).tension || 0);
582
+ if (!this.render.config.readonly) {
583
+ linkLine.on('pointerclick', () => this.render.linkTool.select(linkLine));
584
+ linkLine.on('mouseenter', () => {
585
+ linkLine.opacity(0.5);
586
+ document.body.style.cursor = 'pointer';
587
+ });
588
+ linkLine.on('mouseleave', () => {
589
+ linkLine.opacity(1);
590
+ document.body.style.cursor = 'default';
591
+ });
592
+ }
593
+ this.group.add(linkLine);
594
+ if (!this.render.config.readonly) {
595
+ // 正在拖动效果
596
+ const manualingLine = new Konva.Arrow({
597
+ name: 'manualing-line',
598
+ stroke: '#ff0000',
599
+ strokeWidth: 2,
600
+ points: [],
601
+ dash: [4, 4],
602
+ pointerAtBeginning: false,
603
+ pointerAtEnding: false,
604
+ tension: this.render.getLinkSettings(linkLine).tension
605
+ });
606
+ this.group.add(manualingLine);
607
+ // 拐点(待拐)
608
+ for (let i = 0; i < linkPoints.length - 1; i++) {
609
+ const circle = new Konva.Circle({
610
+ name: 'link-manual-point',
611
+ id: nanoid(),
612
+ pairId: pair.id,
613
+ x: (linkPoints[i][0] + linkPoints[i + 1][0]) / 2,
614
+ y: (linkPoints[i][1] + linkPoints[i + 1][1]) / 2,
615
+ radius: this.render.toStageValue(this.render.bgSize / 2),
616
+ stroke: 'rgba(0,0,255,0.2)',
617
+ strokeWidth: this.render.toStageValue(1),
618
+ linkManualIndex: i // 当前拐点位置
619
+ });
620
+ // hover 效果
621
+ circle.on('mouseenter', () => {
622
+ circle.stroke('rgba(0,0,255,0.8)');
623
+ document.body.style.cursor = 'pointer';
624
+ });
625
+ circle.on('mouseleave', () => {
626
+ if (!circle.attrs.dragStart) {
627
+ circle.stroke('rgba(0,0,255,0.1)');
628
+ document.body.style.cursor = 'default';
629
+ }
630
+ });
631
+ // 拐点操作
632
+ circle.on('mousedown', () => {
633
+ const pos = circle.getAbsolutePosition();
634
+ // 记录操作开始状态
635
+ circle.setAttrs({
636
+ // 开始坐标
637
+ dragStartX: pos.x,
638
+ dragStartY: pos.y,
639
+ // 正在操作
640
+ dragStart: true
641
+ });
642
+ // 标记状态 - 正在操作拐点
643
+ this.state.linkManualing = true;
644
+ });
645
+ this.render.stage.on('mousemove', () => {
646
+ if (circle.attrs.dragStart) {
647
+ // 正在操作
648
+ const pos = this.render.stage.getPointerPosition();
649
+ if (pos) {
650
+ // 磁贴
651
+ const { pos: transformerPos } = this.render.attractTool.attractPoint(pos);
652
+ // 移动拐点
653
+ circle.setAbsolutePosition(transformerPos);
654
+ // 正在拖动效果
655
+ const tempPoints = [...linkPoints];
656
+ tempPoints.splice(circle.attrs.linkManualIndex + 1, 0, [
657
+ this.render.toStageValue(transformerPos.x - stageState.x),
658
+ this.render.toStageValue(transformerPos.y - stageState.y)
659
+ ]);
660
+ manualingLine.points(tempPoints.flat());
661
+ }
662
+ }
663
+ });
664
+ circle.on('mouseup', () => {
665
+ const pos = circle.getAbsolutePosition();
666
+ if (
667
+ Math.abs(pos.x - circle.attrs.dragStartX) > this.option.size ||
668
+ Math.abs(pos.y - circle.attrs.dragStartY) > this.option.size
669
+ ) {
670
+ // 操作移动距离达到阈值
671
+ const stageState = this.render.getStageState();
672
+ // 记录(插入)拐点
673
+ manualPoints.splice(circle.attrs.linkManualIndex, 0, {
674
+ x: this.render.toStageValue(pos.x - stageState.x),
675
+ y: this.render.toStageValue(pos.y - stageState.y)
676
+ });
677
+ manualPointsMap[pair.id] = manualPoints;
678
+ fromGroup.setAttr('manualPointsMap', manualPointsMap);
679
+ }
680
+ // 操作结束
681
+ circle.setAttrs({ dragStart: false });
682
+ // state 操作结束
683
+ this.state.linkManualing = false;
684
+ // 销毁
685
+ circle.destroy();
686
+ manualingLine.destroy();
687
+ // 更新历史
688
+ this.render.updateHistory();
689
+ // 对齐线清除
690
+ this.render.attractTool.alignLinesClear();
691
+ // 重绘
692
+ this.render.redraw([
693
+ Draws.LinkDraw.NAME,
694
+ Draws.RulerDraw.NAME,
695
+ Draws.PreviewDraw.NAME
696
+ ]);
697
+ });
698
+ this.group.add(circle);
699
+ }
700
+ // 拐点(已拐)
701
+ for (let i = 1; i < linkPoints.length - 1; i++) {
702
+ const circle = new Konva.Circle({
703
+ name: 'link-manual-point',
704
+ id: nanoid(),
705
+ pairId: pair.id,
706
+ x: linkPoints[i][0],
707
+ y: linkPoints[i][1],
708
+ radius: this.render.toStageValue(this.render.bgSize / 2),
709
+ stroke: 'rgba(0,100,0,0.2)',
710
+ strokeWidth: this.render.toStageValue(1),
711
+ linkManualIndex: i // 当前拐点位置
712
+ });
713
+ // hover 效果
714
+ circle.on('mouseenter', () => {
715
+ circle.stroke('rgba(0,100,0,1)');
716
+ document.body.style.cursor = 'pointer';
717
+ });
718
+ circle.on('mouseleave', () => {
719
+ if (!circle.attrs.dragStart) {
720
+ circle.stroke('rgba(0,100,0,0.1)');
721
+ document.body.style.cursor = 'default';
722
+ }
723
+ });
724
+ // 拐点操作
725
+ circle.on('mousedown', () => {
726
+ const pos = circle.getAbsolutePosition();
727
+ // 记录操作开始状态
728
+ circle.setAttrs({
729
+ dragStartX: pos.x,
730
+ dragStartY: pos.y,
731
+ dragStart: true
732
+ });
733
+ // 标记状态 - 正在操作拐点
734
+ this.state.linkManualing = true;
735
+ });
736
+ this.render.stage.on('mousemove', () => {
737
+ if (circle.attrs.dragStart) {
738
+ // 正在操作
739
+ const pos = this.render.stage.getPointerPosition();
740
+ if (pos) {
741
+ // 磁贴
742
+ const { pos: transformerPos } = this.render.attractTool.attractPoint(pos);
743
+ // 移动拐点
744
+ circle.setAbsolutePosition(transformerPos);
745
+ // 正在拖动效果
746
+ const tempPoints = [...linkPoints];
747
+ tempPoints[circle.attrs.linkManualIndex] = [
748
+ this.render.toStageValue(transformerPos.x - stageState.x),
749
+ this.render.toStageValue(transformerPos.y - stageState.y)
750
+ ];
751
+ manualingLine.points(tempPoints.flat());
752
+ }
753
+ }
754
+ });
755
+ circle.on('mouseup', () => {
756
+ const pos = circle.getAbsolutePosition();
757
+ if (
758
+ Math.abs(pos.x - circle.attrs.dragStartX) > this.option.size ||
759
+ Math.abs(pos.y - circle.attrs.dragStartY) > this.option.size
760
+ ) {
761
+ // 操作移动距离达到阈值
762
+ const stageState = this.render.getStageState();
763
+ // 记录(更新)拐点
764
+ manualPoints[circle.attrs.linkManualIndex - 1] = {
765
+ x: this.render.toStageValue(pos.x - stageState.x),
766
+ y: this.render.toStageValue(pos.y - stageState.y)
767
+ };
768
+ manualPointsMap[pair.id] = manualPoints;
769
+ fromGroup.setAttr('manualPointsMap', manualPointsMap);
770
+ }
771
+ // 操作结束
772
+ circle.setAttrs({ dragStart: false });
773
+ // state 操作结束
774
+ this.state.linkManualing = false;
775
+ // 销毁
776
+ circle.destroy();
777
+ manualingLine.destroy();
778
+ // 更新历史
779
+ this.render.updateHistory();
780
+ // 对齐线清除
781
+ this.render.attractTool.alignLinesClear();
782
+ // 重绘
783
+ this.render.redraw([
784
+ Draws.LinkDraw.NAME,
785
+ Draws.RulerDraw.NAME,
786
+ Draws.PreviewDraw.NAME
787
+ ]);
788
+ })
789
+ this.group.add(circle);
790
+ }
791
+ }
792
+ }
793
+ } else if (pair.linkType === "bezier") {
794
+ if (fromGroup && toGroup && fromPoint && toPoint) {
795
+ const fromAnchor = fromGroup.findOne(`#${fromPoint.id}`);
796
+ const toAnchor = toGroup.findOne(`#${toPoint.id}`);
797
+ // 锚点信息
798
+ const fromAnchorPos = this.getAnchorPos(fromAnchor);
799
+ const toAnchorPos = this.getAnchorPos(toAnchor);
800
+ // 拐点(已拐)记录
801
+ const manualPointsMap: ManualPointsMap = fromGroup.getAttr('manualPointsMap') ?? ({} as ManualPointsMap);
802
+ const manualPoints = manualPointsMap[pair.id] ?? ([] as ManualPoint[]);
803
+ // 连接点 + 拐点
804
+ const linkPoints = [
805
+ [this.render.toStageValue(fromAnchorPos.x), this.render.toStageValue(fromAnchorPos.y)],
806
+ ...manualPoints.map((o) => [o.x, o.y]),
807
+ [this.render.toStageValue(toAnchorPos.x), this.render.toStageValue(toAnchorPos.y)]
808
+ ];
809
+ // 连接线
810
+ const linkLine = new Konva.Arrow({
811
+ name: 'link-line',
812
+ // 用于删除连接线
813
+ groupId: fromGroup.id(),
814
+ pointId: fromPoint.id,
815
+ pairId: pair.id,
816
+ linkType: pair.linkType,
817
+ points: linkPoints.flat(),
818
+ pointerAtBeginning: false,
819
+ pointerAtEnding: false,
820
+ sceneFunc: BezierSceneFunc
821
+ });
822
+ linkLine.stroke(this.render.getLinkSettings(linkLine).stroke);
823
+ linkLine.strokeWidth(this.render.getLinkSettings(linkLine).strokeWidth);
824
+ linkLine.hitStrokeWidth(Math.max(this.render.getLinkSettings().strokeWidth, 10));
825
+ linkLine.dash(this.render.linkTool.linkCurrent?.attrs.pairId === pair.id ? [1, 1] : []);
826
+ linkLine.fill(this.render.getLinkSettings(linkLine).stroke);
827
+ linkLine.pointerAtBeginning(this.render.getLinkSettings(linkLine).arrowStart);
828
+ linkLine.pointerAtEnding(this.render.getLinkSettings(linkLine).arrowEnd);
829
+ if (!this.render.config.readonly) {
830
+ linkLine.on('pointerclick', () => this.render.linkTool.select(linkLine));
831
+ linkLine.on('mouseenter', () => {
832
+ linkLine.opacity(0.5);
833
+ document.body.style.cursor = 'pointer';
834
+ });
835
+ linkLine.on('mouseleave', () => {
836
+ linkLine.opacity(1);
837
+ document.body.style.cursor = 'default';
838
+ });
839
+ }
840
+ this.group.add(linkLine);
841
+ if (!this.render.config.readonly) {
842
+ // 正在拖动效果
843
+ const manualingLine = new Konva.Arrow({
844
+ name: 'manualing-line',
845
+ stroke: '#ff0000',
846
+ strokeWidth: 2,
847
+ points: [],
848
+ dash: [4, 4],
849
+ pointerAtBeginning: false,
850
+ pointerAtEnding: false,
851
+ sceneFunc: BezierSceneFunc
852
+ });
853
+ this.group.add(manualingLine);
854
+ // 拐点
855
+ if (linkPoints.length <= 3) {
856
+ // 拐点(待拐)
857
+ for (let i = 0; i < linkPoints.length - 1; i++) {
858
+ const circle = new Konva.Circle({
859
+ name: 'link-manual-point',
860
+ id: nanoid(),
861
+ pairId: pair.id,
862
+ x: (linkPoints[i][0] + linkPoints[i + 1][0]) / 2,
863
+ y: (linkPoints[i][1] + linkPoints[i + 1][1]) / 2,
864
+ radius: this.render.toStageValue(this.render.bgSize / 2),
865
+ stroke: 'rgba(0,0,255,0.2)',
866
+ strokeWidth: this.render.toStageValue(1),
867
+ linkManualIndex: i // 当前拐点位置
868
+ });
869
+ // hover 效果
870
+ circle.on('mouseenter', () => {
871
+ circle.stroke('rgba(0,0,255,0.8)');
872
+ document.body.style.cursor = 'pointer';
873
+ });
874
+ circle.on('mouseleave', () => {
875
+ if (!circle.attrs.dragStart) {
876
+ circle.stroke('rgba(0,0,255,0.1)');
877
+ document.body.style.cursor = 'default';
878
+ }
879
+ });
880
+ // 拐点操作
881
+ circle.on('mousedown', () => {
882
+ const pos = circle.getAbsolutePosition();
883
+ // 记录操作开始状态
884
+ circle.setAttrs({
885
+ // 开始坐标
886
+ dragStartX: pos.x,
887
+ dragStartY: pos.y,
888
+ // 正在操作
889
+ dragStart: true
890
+ });
891
+ // 标记状态 - 正在操作拐点
892
+ this.state.linkManualing = true;
893
+ });
894
+ this.render.stage.on('mousemove', () => {
895
+ if (circle.attrs.dragStart) {
896
+ // 正在操作
897
+ const pos = this.render.stage.getPointerPosition();
898
+ if (pos) {
899
+ // 磁贴
900
+ const { pos: transformerPos } = this.render.attractTool.attractPoint(pos);
901
+ // 移动拐点
902
+ circle.setAbsolutePosition(transformerPos);
903
+ // 正在拖动效果
904
+ const tempPoints = [...linkPoints];
905
+ tempPoints.splice(circle.attrs.linkManualIndex + 1, 0, [
906
+ this.render.toStageValue(transformerPos.x - stageState.x),
907
+ this.render.toStageValue(transformerPos.y - stageState.y)
908
+ ]);
909
+ manualingLine.points(tempPoints.flat());
910
+ }
911
+ }
912
+ });
913
+ circle.on('mouseup', () => {
914
+ const pos = circle.getAbsolutePosition();
915
+ if (
916
+ Math.abs(pos.x - circle.attrs.dragStartX) > this.option.size ||
917
+ Math.abs(pos.y - circle.attrs.dragStartY) > this.option.size
918
+ ) {
919
+ // 操作移动距离达到阈值
920
+ const stageState = this.render.getStageState();
921
+ // 记录(插入)拐点
922
+ manualPoints.splice(circle.attrs.linkManualIndex, 0, {
923
+ x: this.render.toStageValue(pos.x - stageState.x),
924
+ y: this.render.toStageValue(pos.y - stageState.y)
925
+ });
926
+ manualPointsMap[pair.id] = manualPoints;
927
+ fromGroup.setAttr('manualPointsMap', manualPointsMap);
928
+ }
929
+ // 操作结束
930
+ circle.setAttrs({ dragStart: false });
931
+ // state 操作结束
932
+ this.state.linkManualing = false;
933
+ // 销毁
934
+ circle.destroy();
935
+ manualingLine.destroy();
936
+ // 更新历史
937
+ this.render.updateHistory();
938
+ // 对齐线清除
939
+ this.render.attractTool.alignLinesClear();
940
+ // 重绘
941
+ this.render.redraw([
942
+ Draws.LinkDraw.NAME,
943
+ Draws.RulerDraw.NAME,
944
+ Draws.PreviewDraw.NAME
945
+ ]);
946
+ });
947
+ this.group.add(circle);
948
+ }
949
+ }
950
+ // 拐点(已拐)
951
+ for (let i = 1; i < linkPoints.length - 1; i++) {
952
+ const circle = new Konva.Circle({
953
+ name: 'link-manual-point',
954
+ id: nanoid(),
955
+ pairId: pair.id,
956
+ x: linkPoints[i][0],
957
+ y: linkPoints[i][1],
958
+ radius: this.render.toStageValue(this.render.bgSize / 2),
959
+ stroke: 'rgba(0,100,0,0.2)',
960
+ strokeWidth: this.render.toStageValue(1),
961
+ linkManualIndex: i // 当前拐点位置
962
+ });
963
+ // hover 效果
964
+ circle.on('mouseenter', () => {
965
+ circle.stroke('rgba(0,100,0,1)');
966
+ document.body.style.cursor = 'pointer';
967
+ });
968
+ circle.on('mouseleave', () => {
969
+ if (!circle.attrs.dragStart) {
970
+ circle.stroke('rgba(0,100,0,0.1)');
971
+ document.body.style.cursor = 'default';
972
+ }
973
+ });
974
+ // 拐点操作
975
+ circle.on('mousedown', () => {
976
+ const pos = circle.getAbsolutePosition();
977
+ // 记录操作开始状态
978
+ circle.setAttrs({
979
+ dragStartX: pos.x,
980
+ dragStartY: pos.y,
981
+ dragStart: true
982
+ });
983
+ // 标记状态 - 正在操作拐点
984
+ this.state.linkManualing = true;
985
+ });
986
+ this.render.stage.on('mousemove', () => {
987
+ if (circle.attrs.dragStart) {
988
+ // 正在操作
989
+ const pos = this.render.stage.getPointerPosition();
990
+ if (pos) {
991
+ // 磁贴
992
+ const { pos: transformerPos } = this.render.attractTool.attractPoint(pos);
993
+ // 移动拐点
994
+ circle.setAbsolutePosition(transformerPos);
995
+ // 正在拖动效果
996
+ const tempPoints = [...linkPoints]
997
+ tempPoints[circle.attrs.linkManualIndex] = [
998
+ this.render.toStageValue(transformerPos.x - stageState.x),
999
+ this.render.toStageValue(transformerPos.y - stageState.y)
1000
+ ];
1001
+ manualingLine.points(tempPoints.flat());
1002
+ }
1003
+ }
1004
+ });
1005
+ circle.on('mouseup', () => {
1006
+ const pos = circle.getAbsolutePosition();
1007
+ if (
1008
+ Math.abs(pos.x - circle.attrs.dragStartX) > this.option.size ||
1009
+ Math.abs(pos.y - circle.attrs.dragStartY) > this.option.size
1010
+ ) {
1011
+ // 操作移动距离达到阈值
1012
+ const stageState = this.render.getStageState();
1013
+ // 记录(更新)拐点
1014
+ manualPoints[circle.attrs.linkManualIndex - 1] = {
1015
+ x: this.render.toStageValue(pos.x - stageState.x),
1016
+ y: this.render.toStageValue(pos.y - stageState.y)
1017
+ };
1018
+ manualPointsMap[pair.id] = manualPoints;
1019
+ fromGroup.setAttr('manualPointsMap', manualPointsMap);
1020
+ }
1021
+ // 操作结束
1022
+ circle.setAttrs({ dragStart: false });
1023
+ // state 操作结束
1024
+ this.state.linkManualing = false;
1025
+ // 销毁
1026
+ circle.destroy();
1027
+ manualingLine.destroy();
1028
+ // 更新历史
1029
+ this.render.updateHistory();
1030
+ // 对齐线清除
1031
+ this.render.attractTool.alignLinesClear();
1032
+ // 重绘
1033
+ this.render.redraw([
1034
+ Draws.LinkDraw.NAME,
1035
+ Draws.RulerDraw.NAME,
1036
+ Draws.PreviewDraw.NAME
1037
+ ]);
1038
+ });
1039
+ this.group.add(circle);
1040
+ }
1041
+ }
1042
+ }
1043
+ } else if (pair.linkType === "straight") {
1044
+ // 直线
1045
+ if (fromGroup && toGroup && fromPoint && toPoint) {
1046
+ const fromAnchor = fromGroup.findOne(`#${fromPoint.id}`);
1047
+ const toAnchor = toGroup.findOne(`#${toPoint.id}`);
1048
+ // 锚点信息
1049
+ const fromAnchorPos = this.getAnchorPos(fromAnchor);
1050
+ const toAnchorPos = this.getAnchorPos(toAnchor);
1051
+ const linkLine = new Konva.Arrow({
1052
+ name: 'link-line',
1053
+ // 用于删除连接线
1054
+ groupId: fromGroup.id(),
1055
+ pointId: fromPoint.id,
1056
+ pairId: pair.id,
1057
+ linkType: pair.linkType,
1058
+ points: [
1059
+ [this.render.toStageValue(fromAnchorPos.x), this.render.toStageValue(fromAnchorPos.y)],
1060
+ [this.render.toStageValue(toAnchorPos.x), this.render.toStageValue(toAnchorPos.y)]
1061
+ ].flat(),
1062
+ pointerAtBeginning: false,
1063
+ pointerAtEnding: false
1064
+ });
1065
+ linkLine.stroke(this.render.getLinkSettings(linkLine).stroke);
1066
+ linkLine.strokeWidth(this.render.getLinkSettings(linkLine).strokeWidth);
1067
+ linkLine.hitStrokeWidth(Math.max(this.render.getLinkSettings().strokeWidth, 10));
1068
+ linkLine.dash(this.render.linkTool.linkCurrent?.attrs.pairId === pair.id ? [1, 1] : []);
1069
+ linkLine.fill(this.render.getLinkSettings(linkLine).stroke);
1070
+ linkLine.pointerAtBeginning(this.render.getLinkSettings(linkLine).arrowStart);
1071
+ linkLine.pointerAtEnding(this.render.getLinkSettings(linkLine).arrowEnd);
1072
+
1073
+ if (!this.render.config.readonly) {
1074
+ linkLine.on('pointerclick', () => this.render.linkTool.select(linkLine));
1075
+ linkLine.on('mouseenter', () => {
1076
+ linkLine.opacity(0.5);
1077
+ document.body.style.cursor = 'pointer';
1078
+ });
1079
+ linkLine.on('mouseleave', () => {
1080
+ linkLine.opacity(1);
1081
+ document.body.style.cursor = 'default';
1082
+ });
1083
+ }
1084
+ this.group.add(linkLine);
1085
+ }
1086
+ } else {
1087
+ // 自动
1088
+ // 最小区域
1089
+ const fromGroupLinkArea = this.getGroupLinkArea(fromGroup);
1090
+ const toGroupLinkArea = this.getGroupLinkArea(toGroup);
1091
+ // 两区域的最短距离
1092
+ const groupDistance = this.getGroupPairDistance(fromGroupLinkArea, toGroupLinkArea);
1093
+ // 不可通过区域
1094
+ const fromGroupForbiddenArea = this.getGroupForbiddenArea(fromGroupLinkArea, groupDistance - 2);
1095
+ const toGroupForbiddenArea = this.getGroupForbiddenArea(toGroupLinkArea, groupDistance - 2);
1096
+ // 两区域扩展
1097
+ const groupForbiddenArea = this.getGroupPairArea(fromGroupForbiddenArea, toGroupForbiddenArea);
1098
+ // 连线通过区域
1099
+ const groupAccessArea = this.getGroupPairArea(this.getGroupAccessArea(fromGroupForbiddenArea, groupDistance), this.getGroupAccessArea(toGroupForbiddenArea, groupDistance));
1100
+ if (fromGroup && toGroup && fromPoint && toPoint) {
1101
+ const fromAnchor = fromGroup.findOne(`#${fromPoint.id}`);
1102
+ const toAnchor = toGroup.findOne(`#${toPoint.id}`);
1103
+ // 锚点信息
1104
+ const fromAnchorPos = this.getAnchorPos(fromAnchor);
1105
+ const toAnchorPos = this.getAnchorPos(toAnchor);
1106
+ if (fromAnchor && toAnchor) {
1107
+ // 连接出入口
1108
+ const fromEntry: Konva.Vector2d = this.getEntry(fromAnchor, fromGroupForbiddenArea, groupDistance);
1109
+ const toEntry: Konva.Vector2d = this.getEntry(toAnchor, toGroupForbiddenArea, groupDistance);
1110
+ type matrixPoint = { x: number, y: number, type?: 'from' | 'to' | 'from-entry' | 'to-entry' };
1111
+ // 可能点
1112
+ let matrixPoints: matrixPoint[] = [];
1113
+ // 通过区域 四角
1114
+ matrixPoints.push({ x: groupAccessArea.x1, y: groupAccessArea.y1 });
1115
+ matrixPoints.push({ x: groupAccessArea.x2, y: groupAccessArea.y2 });
1116
+ matrixPoints.push({ x: groupAccessArea.x1, y: groupAccessArea.y2 });
1117
+ matrixPoints.push({ x: groupAccessArea.x2, y: groupAccessArea.y1 });
1118
+ // 最小区域 四角
1119
+ matrixPoints.push({ x: groupForbiddenArea.x1, y: groupForbiddenArea.y1 });
1120
+ matrixPoints.push({ x: groupForbiddenArea.x2, y: groupForbiddenArea.y2 });
1121
+ matrixPoints.push({ x: groupForbiddenArea.x1, y: groupForbiddenArea.y2 });
1122
+ matrixPoints.push({ x: groupForbiddenArea.x2, y: groupForbiddenArea.y1 });
1123
+ // 起点
1124
+ matrixPoints.push({ ...fromAnchorPos, type: 'from' });
1125
+ // 起点 出口
1126
+ matrixPoints.push({ ...fromEntry, type: 'from-entry' });
1127
+ // 终点
1128
+ matrixPoints.push({ ...toAnchorPos, type: 'to' });
1129
+ // 终点 入口
1130
+ matrixPoints.push({ ...toEntry, type: 'to-entry' });
1131
+ // 通过区域 中点
1132
+ matrixPoints.push(this.getGroupPairCenter(fromGroupForbiddenArea, toGroupForbiddenArea));
1133
+ // 去重
1134
+ matrixPoints = matrixPoints.reduce(
1135
+ (arr, item) => {
1136
+ if (item.type === void 0) {
1137
+ if (arr.findIndex((o) => o.x === item.x && o.y === item.y) < 0) {
1138
+ arr.push(item);
1139
+ }
1140
+ } else {
1141
+ const idx = arr.findIndex((o) => o.x === item.x && o.y === item.y)
1142
+ if (idx > -1) {
1143
+ arr.splice(idx, 1);
1144
+ }
1145
+ arr.push(item);
1146
+ }
1147
+ return arr;
1148
+ },
1149
+ [] as typeof matrixPoints
1150
+ );
1151
+ const columns = [
1152
+ ...matrixPoints.map((o) => o.x),
1153
+ // 增加列
1154
+ fromGroupForbiddenArea.x1,
1155
+ fromGroupForbiddenArea.x2,
1156
+ toGroupForbiddenArea.x1,
1157
+ toGroupForbiddenArea.x2
1158
+ ].sort((a, b) => a - b);
1159
+ // 去重
1160
+ for (let x = columns.length - 1; x > 0; x--) {
1161
+ if (columns[x] === columns[x - 1]) {
1162
+ columns.splice(x, 1);
1163
+ }
1164
+ }
1165
+ const rows = [
1166
+ ...matrixPoints.map((o) => o.y),
1167
+ // 增加行
1168
+ fromGroupForbiddenArea.y1,
1169
+ fromGroupForbiddenArea.y2,
1170
+ toGroupForbiddenArea.y1,
1171
+ toGroupForbiddenArea.y2
1172
+ ].sort((a, b) => a - b);
1173
+ // 去重
1174
+ for (let y = rows.length - 1; y > 0; y--) {
1175
+ if (rows[y] === rows[y - 1]) {
1176
+ rows.splice(y, 1);
1177
+ }
1178
+ }
1179
+ // 屏蔽区域(序号)
1180
+ const columnFromStart = columns.findIndex((o) => o === fromGroupForbiddenArea.x1);
1181
+ const columnFromEnd = columns.findIndex((o) => o === fromGroupForbiddenArea.x2);
1182
+ const rowFromStart = rows.findIndex((o) => o === fromGroupForbiddenArea.y1);
1183
+ const rowFromEnd = rows.findIndex((o) => o === fromGroupForbiddenArea.y2);
1184
+ const columnToStart = columns.findIndex((o) => o === toGroupForbiddenArea.x1);
1185
+ const columnToEnd = columns.findIndex((o) => o === toGroupForbiddenArea.x2);
1186
+ const rowToStart = rows.findIndex((o) => o === toGroupForbiddenArea.y1);
1187
+ const rowToEnd = rows.findIndex((o) => o === toGroupForbiddenArea.y2);
1188
+ // 算法矩阵起点、终点
1189
+ let matrixStart: Konva.Vector2d | null = null;
1190
+ let matrixEnd: Konva.Vector2d | null = null;
1191
+ // 算法地图矩阵
1192
+ const matrix: Array<number[]> = [];
1193
+ for (let y = 0; y < rows.length; y++) {
1194
+ // 新增行
1195
+ if (matrix[y] === void 0) {
1196
+ matrix[y] = [];
1197
+ }
1198
+ for (let x = 0; x < columns.length; x++) {
1199
+ // 不可通过区域
1200
+ if (
1201
+ x >= columnFromStart &&
1202
+ x <= columnFromEnd &&
1203
+ y >= rowFromStart &&
1204
+ y <= rowFromEnd
1205
+ ) {
1206
+ matrix[y][x] = 2;
1207
+ } else if (
1208
+ x >= columnToStart &&
1209
+ x <= columnToEnd &&
1210
+ y >= rowToStart &&
1211
+ y <= rowToEnd
1212
+ ) {
1213
+ matrix[y][x] = 2;
1214
+ } else {
1215
+ // 可通过区域
1216
+ matrix[y][x] = 0;
1217
+ }
1218
+ // 出口、入口 -> 算法 起点、终点
1219
+ if (columns[x] === fromEntry.x && rows[y] === fromEntry.y) {
1220
+ matrix[y][x] = 1;
1221
+ matrixStart = { x, y };
1222
+ }
1223
+ if (columns[x] === toEntry.x && rows[y] === toEntry.y) {
1224
+ matrix[y][x] = 1;
1225
+ matrixEnd = { x, y };
1226
+ }
1227
+ // 没有定义方向(给于十字可通过区域)
1228
+ // 如,从:
1229
+ // 1 1 1
1230
+ // 1 0 1
1231
+ // 1 1 1
1232
+ // 变成:
1233
+ // 1 0 1
1234
+ // 0 0 0
1235
+ // 1 0 1
1236
+ if (!fromAnchor.attrs.direction) {
1237
+ if (columns[x] === fromEntry.x || rows[y] === fromEntry.y) {
1238
+ if (
1239
+ x >= columnFromStart &&
1240
+ x <= columnFromEnd &&
1241
+ y >= rowFromStart &&
1242
+ y <= rowFromEnd
1243
+ ) {
1244
+ matrix[y][x] = 1;
1245
+ }
1246
+ }
1247
+ }
1248
+ if (!toAnchor.attrs.direction) {
1249
+ if (columns[x] === toEntry.x || rows[y] === toEntry.y) {
1250
+ if (
1251
+ x >= columnToStart &&
1252
+ x <= columnToEnd &&
1253
+ y >= rowToStart &&
1254
+ y <= rowToEnd
1255
+ ) {
1256
+ matrix[y][x] = 1;
1257
+ }
1258
+ }
1259
+ }
1260
+ }
1261
+ }
1262
+
1263
+ if (matrixStart && matrixEnd) {
1264
+ const way = aStar({ from: matrixStart, to: matrixEnd, matrix, maxCost: 2 });
1265
+ const linkLine = new Konva.Arrow({
1266
+ name: 'link-line',
1267
+ // 用于删除连接线
1268
+ groupId: fromGroup.id(),
1269
+ pointId: fromPoint.id,
1270
+ pairId: pair.id,
1271
+ linkType: pair.linkType, // 记录 连接线 类型
1272
+ points: [
1273
+ [this.render.toStageValue(fromAnchorPos.x), this.render.toStageValue(fromAnchorPos.y)], // 补充 起点
1274
+ ...way.map((o) => [this.render.toStageValue(columns[o.x]), this.render.toStageValue(rows[o.y])]),
1275
+ [this.render.toStageValue(toAnchorPos.x), this.render.toStageValue(toAnchorPos.y)] // 补充 终点
1276
+ ].flat(),
1277
+ pointerAtBeginning: false,
1278
+ pointerAtEnding: false
1279
+ });
1280
+ linkLine.stroke(this.render.getLinkSettings(linkLine).stroke);
1281
+ linkLine.strokeWidth(this.render.getLinkSettings(linkLine).strokeWidth);
1282
+ linkLine.hitStrokeWidth(Math.max(this.render.getLinkSettings().strokeWidth, 10));
1283
+ linkLine.dash(this.render.linkTool.linkCurrent?.attrs.pairId === pair.id ? [1, 1] : []);
1284
+ linkLine.fill(this.render.getLinkSettings(linkLine).stroke);
1285
+ linkLine.pointerAtBeginning(this.render.getLinkSettings(linkLine).arrowStart);
1286
+ linkLine.pointerAtEnding(this.render.getLinkSettings(linkLine).arrowEnd);
1287
+ if (!this.render.config.readonly) {
1288
+ linkLine.on('pointerclick', () => this.render.linkTool.select(linkLine));
1289
+ linkLine.on('mouseenter', () => {
1290
+ linkLine.opacity(0.5);
1291
+ document.body.style.cursor = 'pointer';
1292
+ });
1293
+ linkLine.on('mouseleave', () => {
1294
+ linkLine.opacity(1);
1295
+ document.body.style.cursor = 'default';
1296
+ });
1297
+ }
1298
+ this.group.add(linkLine);
1299
+ }
1300
+ }
1301
+ }
1302
+ }
1303
+ }
1304
+ }
1305
+
1306
+ if (!this.render.config.readonly) {
1307
+ // 连接点
1308
+ for (const point of points) {
1309
+ const group = groups.find((o) => o.id() === point.groupId);
1310
+ // 选择中
1311
+ if (group && !group.getAttr('selected')) {
1312
+ const anchor = this.render.layer.findOne(`#${point.id}`);
1313
+ if (anchor) {
1314
+ const circle = new Konva.Circle({
1315
+ name: 'link-point',
1316
+ id: point.id,
1317
+ groupId: group.id(),
1318
+ x: this.render.toStageValue(anchor.absolutePosition().x - stageState.x),
1319
+ y: this.render.toStageValue(anchor.absolutePosition().y - stageState.y),
1320
+ radius: this.render.toStageValue(this.option.size),
1321
+ stroke: 'rgba(255,0,0,0.2)',
1322
+ strokeWidth: this.render.toStageValue(1),
1323
+ // 调整中,不显示连接点
1324
+ opacity: point.visible && !(this.render.draws[Draws.GraphDraw.NAME] as Draws.GraphDraw).state.adjusting ? 1 : 0
1325
+ });
1326
+ // hover 效果
1327
+ circle.on('mouseenter', () => {
1328
+ circle.stroke('rgba(255,0,0,0.5)');
1329
+ circle.opacity(1);
1330
+ document.body.style.cursor = 'pointer';
1331
+ });
1332
+ circle.on('mouseleave', () => {
1333
+ circle.stroke('rgba(255,0,0,0.2)');
1334
+ circle.opacity(0);
1335
+ document.body.style.cursor = 'default';
1336
+ });
1337
+ circle.on('mousedown', () => {
1338
+ this.render.selectionTool.selectingClear();
1339
+ this.render.linkTool.selectingClear();
1340
+ const pos = this.render.stage.getPointerPosition();
1341
+ if (pos) {
1342
+ // 临时 连接线 画
1343
+ this.state.linkingLine = {
1344
+ group: group,
1345
+ circle: circle,
1346
+ line: new Konva.Line({
1347
+ name: 'linking-line',
1348
+ points: [
1349
+ [circle.x(), circle.y()],
1350
+ [
1351
+ this.render.toStageValue(pos.x - stageState.x),
1352
+ this.render.toStageValue(pos.y - stageState.y)
1353
+ ]
1354
+ ].flat(),
1355
+ stroke: 'blue',
1356
+ strokeWidth: 1
1357
+ })
1358
+ };
1359
+ this.layer.add(this.state.linkingLine.line);
1360
+ }
1361
+ });
1362
+ circle.on('mouseup', () => {
1363
+ if (this.state.linkingLine) {
1364
+ const line = this.state.linkingLine;
1365
+ // 不同连接点
1366
+ if (line.circle.id() !== circle.id()) {
1367
+ const toGroup = groups.find((o) => o.id() === circle.getAttr('groupId'));
1368
+ if (toGroup) {
1369
+ const fromPoint = points.find((o) => o.id === line.circle.id());
1370
+ if (fromPoint) {
1371
+ const toPoint = points.find((o) => o.id === line.circle.id());
1372
+ if (toPoint) {
1373
+ if (Array.isArray(fromPoint.pairs)) {
1374
+ fromPoint.pairs = [
1375
+ ...fromPoint.pairs,
1376
+ {
1377
+ id: nanoid(),
1378
+ from: {
1379
+ groupId: line.group.id(),
1380
+ pointId: line.circle.id()
1381
+ },
1382
+ to: {
1383
+ groupId: circle.getAttr('groupId'),
1384
+ pointId: circle.id()
1385
+ },
1386
+ linkType: this.state.linkType // 记录 连接线 类型
1387
+ }
1388
+ ];
1389
+ }
1390
+ // 更新历史
1391
+ this.render.updateHistory();
1392
+ // 对齐线清除
1393
+ this.render.attractTool.alignLinesClear();
1394
+ // 重绘
1395
+ this.render.redraw([
1396
+ Draws.LinkDraw.NAME,
1397
+ Draws.RulerDraw.NAME,
1398
+ Draws.PreviewDraw.NAME
1399
+ ]);
1400
+ }
1401
+ }
1402
+ }
1403
+ }
1404
+ // 临时 连接线 移除
1405
+ this.state.linkingLine?.line.destroy();
1406
+ this.state.linkingLine = null;
1407
+ }
1408
+ });
1409
+ this.group.add(circle);
1410
+ }
1411
+ }
1412
+ }
1413
+ }
1414
+ }
1415
+ }