aldehyde 0.2.489 → 0.2.491

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 (691) 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/date-picker/index.js +9 -9
  14. package/lib/controls/date-picker/index.js.map +1 -1
  15. package/lib/controls/entity-select/entity-select.d.ts.map +1 -1
  16. package/lib/controls/entity-select/index.css +7 -7
  17. package/lib/controls/entity-select/lab-tree-select.d.ts.map +1 -1
  18. package/lib/controls/entity-select/popover-entity-select.d.ts.map +1 -1
  19. package/lib/controls/file-view/index.less +9 -9
  20. package/lib/controls/html-editor/index.less +67 -67
  21. package/lib/controls/icon-selector/icon/aldehyde-menu-icon/iconfont.css +147 -147
  22. package/lib/controls/icon-selector/icon/phonenode-menu-icon/iconfont.css +63 -63
  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 +4 -0
  37. package/lib/custom-page/dtmpl-custom-edit-modal-page.d.ts.map +1 -1
  38. package/lib/custom-page/dtmpl-custom-edit-modal-page.js +3 -1
  39. package/lib/custom-page/dtmpl-custom-edit-modal-page.js.map +1 -1
  40. package/lib/detail/button/bottom-submit-button-bar.d.ts.map +1 -1
  41. package/lib/detail/button/cquery-button-bar.d.ts.map +1 -1
  42. package/lib/detail/button/fix-right-submit-button-bar.d.ts.map +1 -1
  43. package/lib/detail/button/index.css +42 -42
  44. package/lib/detail/dtmpl.css +72 -72
  45. package/lib/detail/edit/fields-edit-card.d.ts.map +1 -1
  46. package/lib/detail/edit/modal-row-edit.d.ts.map +1 -1
  47. package/lib/detail/edit/popover-edit-card.d.ts.map +1 -1
  48. package/lib/detail/rightbar/index.css +34 -34
  49. package/lib/detail/rightbar/index.d.ts.map +1 -1
  50. package/lib/detail/view/act-dtmpl-view.d.ts.map +1 -1
  51. package/lib/detail/view/field-view-group.d.ts.map +1 -1
  52. package/lib/detail/view/modal-dtmpl-view.d.ts.map +1 -1
  53. package/lib/detail/view/snapshot-timeline.d.ts.map +1 -1
  54. package/lib/detail/view/tab-act-dtmpl-view.d.ts.map +1 -1
  55. package/lib/draw-canvas-edit/components/asset-bar/index.less +35 -35
  56. package/lib/draw-canvas-edit/components/main-header/index.less +23 -23
  57. package/lib/draw-canvas-edit/components/render/components/index.less +60 -60
  58. package/lib/draw-canvas-edit/components/render/components/workstation-component.js +6 -6
  59. package/lib/draw-canvas-edit/index.less +48 -48
  60. package/lib/draw-canvas-view/index.less +66 -66
  61. package/lib/export/export-frame.css +2 -2
  62. package/lib/export/export-frame.d.ts.map +1 -1
  63. package/lib/export/select-code-export-frame.d.ts.map +1 -1
  64. package/lib/form/dtmpl-form.css +3 -3
  65. package/lib/form/dtmpl-form.d.ts.map +1 -1
  66. package/lib/form/field-group-form.d.ts.map +1 -1
  67. package/lib/form/form-Item-group.d.ts.map +1 -1
  68. package/lib/form/index.css +12 -12
  69. package/lib/import/excel-import.d.ts.map +1 -1
  70. package/lib/import/index.css +53 -53
  71. package/lib/import/template.css +50 -50
  72. package/lib/layout/common.css +64 -64
  73. package/lib/layout/coverstyle.css +51 -51
  74. package/lib/layout/footer/index.css +5 -5
  75. package/lib/layout/header/index.css +122 -122
  76. package/lib/layout/menu/block.css +7 -7
  77. package/lib/layout/menu/block.d.ts.map +1 -1
  78. package/lib/layout/menu/l2menu-quick-bar.d.ts.map +1 -1
  79. package/lib/layout/menu/menu-2layers.d.ts.map +1 -1
  80. package/lib/layout/menu/message-bar.less +73 -73
  81. package/lib/layout/menu/reset-password.d.ts.map +1 -1
  82. package/lib/layout/menu/user-bar.d.ts.map +1 -1
  83. package/lib/layout/menu/userinfo-bar.d.ts.map +1 -1
  84. package/lib/layout/sidebar/index.css +57 -57
  85. package/lib/layout2/components/system-messages.js +1 -1
  86. package/lib/layout2/components/system-messages.js.map +1 -1
  87. package/lib/layout2/components/user-notification.js +1 -1
  88. package/lib/layout2/components/user-notification.js.map +1 -1
  89. package/lib/layout2/css/header.css +41 -41
  90. package/lib/layout2/css/sider.less +17 -17
  91. package/lib/layout2/css/tabs-layout.less +18 -18
  92. package/lib/layout3/css/header.less +195 -195
  93. package/lib/layout3/css/main.less +161 -161
  94. package/lib/layout3/css/sider.less +32 -32
  95. package/lib/layout3/css/tabs-layout.less +38 -38
  96. package/lib/layout4/css/header.less +196 -196
  97. package/lib/layout4/css/main.less +154 -154
  98. package/lib/layout4/css/sider.less +37 -37
  99. package/lib/layout4/css/tabs-layout.less +42 -42
  100. package/lib/layout5/css/header.less +35 -35
  101. package/lib/layout5/css/sider.less +18 -18
  102. package/lib/list/calendar/index.less +20 -20
  103. package/lib/list/card-list/index.less +154 -154
  104. package/lib/list/gantt/index.less +8 -8
  105. package/lib/list/vertical-list/index.less +208 -208
  106. package/lib/login/index.css +19 -19
  107. package/lib/login/login.d.ts.map +1 -1
  108. package/lib/login/vertify/index.css +143 -143
  109. package/lib/login3/index.less +136 -136
  110. package/lib/lowcode-components/act-table/index.less +26 -26
  111. package/lib/lowcode-components/base-button/index.less +7 -7
  112. package/lib/lowcode-components/base-map/index.js +6 -6
  113. package/lib/lowcode-components/base-radio/index.less +23 -23
  114. package/lib/lowcode-components/base-table/index.less +61 -61
  115. package/lib/lowcode-components/base-tabs/index.less +14 -14
  116. package/lib/lowcode-components/base-text/index.less +19 -19
  117. package/lib/lowcode-components/border/border10/index.less +26 -26
  118. package/lib/lowcode-components/border/border11/index.js +46 -46
  119. package/lib/lowcode-components/border/border11/index.less +17 -17
  120. package/lib/lowcode-components/border/border12/index.js +13 -13
  121. package/lib/lowcode-components/border/border12/index.less +13 -13
  122. package/lib/lowcode-components/border/border13/index.js +5 -5
  123. package/lib/lowcode-components/border/border13/index.less +13 -13
  124. package/lib/lowcode-components/border/border2/index.less +17 -17
  125. package/lib/lowcode-components/border/border3/index.less +25 -25
  126. package/lib/lowcode-components/border/border4/index.js +2 -2
  127. package/lib/lowcode-components/border/border4/index.less +72 -72
  128. package/lib/lowcode-components/border/border5/index.js +2 -2
  129. package/lib/lowcode-components/border/border5/index.less +35 -35
  130. package/lib/lowcode-components/border/border6/index.less +17 -17
  131. package/lib/lowcode-components/border/border7/index.less +26 -26
  132. package/lib/lowcode-components/border/border8/index.less +13 -13
  133. package/lib/lowcode-components/border/border9/index.js +14 -14
  134. package/lib/lowcode-components/border/border9/index.less +13 -13
  135. package/lib/lowcode-components/column-chart/index.d.ts +1 -0
  136. package/lib/lowcode-components/column-chart/index.d.ts.map +1 -1
  137. package/lib/lowcode-components/column-chart/index.js +49 -7
  138. package/lib/lowcode-components/column-chart/index.js.map +1 -1
  139. package/lib/lowcode-components/data-number/index.less +10 -10
  140. package/lib/lowcode-components/date-time/index.less +4 -4
  141. package/lib/lowcode-components/decoration/decoration1/index.less +7 -7
  142. package/lib/lowcode-components/decoration/decoration10/index.js +3 -3
  143. package/lib/lowcode-components/decoration/decoration10/index.less +5 -5
  144. package/lib/lowcode-components/decoration/decoration11/index.less +5 -5
  145. package/lib/lowcode-components/decoration/decoration2/index.less +6 -6
  146. package/lib/lowcode-components/decoration/decoration3/index.less +7 -7
  147. package/lib/lowcode-components/decoration/decoration4/index.less +29 -29
  148. package/lib/lowcode-components/decoration/decoration5/index.less +3 -3
  149. package/lib/lowcode-components/decoration/decoration6/index.less +7 -7
  150. package/lib/lowcode-components/decoration/decoration7/index.less +4 -4
  151. package/lib/lowcode-components/decoration/decoration8/index.less +14 -14
  152. package/lib/lowcode-components/decoration/decoration9/index.less +4 -4
  153. package/lib/lowcode-components/effectScatter-map/index.js +6 -6
  154. package/lib/lowcode-components/effectScatter-map-3d/index.js +6 -6
  155. package/lib/lowcode-components/four-angle-glow-border/index.less +49 -49
  156. package/lib/lowcode-components/line-bar-chart/index.d.ts +2 -1
  157. package/lib/lowcode-components/line-bar-chart/index.d.ts.map +1 -1
  158. package/lib/lowcode-components/line-bar-chart/index.js +53 -11
  159. package/lib/lowcode-components/line-bar-chart/index.js.map +1 -1
  160. package/lib/lowcode-components/line-chart/index.d.ts +1 -0
  161. package/lib/lowcode-components/line-chart/index.d.ts.map +1 -1
  162. package/lib/lowcode-components/line-chart/index.js +52 -10
  163. package/lib/lowcode-components/line-chart/index.js.map +1 -1
  164. package/lib/lowcode-components/lowcode-view/component/font/FontGlobal.css +26 -26
  165. package/lib/lowcode-components/lowcode-view/component/screen-fit/index.less +13 -13
  166. package/lib/lowcode-components/lowcode-view/index.d.ts.map +1 -1
  167. package/lib/lowcode-components/lowcode-view/index.js +3 -1
  168. package/lib/lowcode-components/lowcode-view/index.js.map +1 -1
  169. package/lib/lowcode-components/lowcode-view/index.less +19 -19
  170. package/lib/lowcode-components/search-form/index.less +25 -25
  171. package/lib/lowcode-components/text-scroller/index.less +28 -28
  172. package/lib/module/dtmpl-edit-card.d.ts +2 -0
  173. package/lib/module/dtmpl-edit-card.d.ts.map +1 -1
  174. package/lib/module/dtmpl-edit-card.js +15 -12
  175. package/lib/module/dtmpl-edit-card.js.map +1 -1
  176. package/lib/module/dtmpl-edit-drawer.d.ts +1 -0
  177. package/lib/module/dtmpl-edit-drawer.d.ts.map +1 -1
  178. package/lib/module/dtmpl-edit-drawer.js.map +1 -1
  179. package/lib/module/dtmpl-edit-modal.d.ts +1 -0
  180. package/lib/module/dtmpl-edit-modal.d.ts.map +1 -1
  181. package/lib/module/dtmpl-edit-modal.js.map +1 -1
  182. package/lib/module/dtmpl-edit-page.d.ts +2 -0
  183. package/lib/module/dtmpl-edit-page.d.ts.map +1 -1
  184. package/lib/module/dtmpl-edit-page.js +16 -12
  185. package/lib/module/dtmpl-edit-page.js.map +1 -1
  186. package/lib/module/index.less +4 -4
  187. package/lib/module/ltmpl-modal.d.ts.map +1 -1
  188. package/lib/module/ltmpl-table.d.ts +4 -0
  189. package/lib/module/ltmpl-table.d.ts.map +1 -1
  190. package/lib/module/ltmpl-table.js +10 -6
  191. package/lib/module/ltmpl-table.js.map +1 -1
  192. package/lib/routable/index.less +25 -25
  193. package/lib/routable/ltmpl-route.d.ts +1 -0
  194. package/lib/routable/ltmpl-route.d.ts.map +1 -1
  195. package/lib/routable/ltmpl-route.js +5 -3
  196. package/lib/routable/ltmpl-route.js.map +1 -1
  197. package/lib/routable/splitview-ltmpl-route.d.ts.map +1 -1
  198. package/lib/routable/splitview-ltmpl-route.js +4 -2
  199. package/lib/routable/splitview-ltmpl-route.js.map +1 -1
  200. package/lib/table/act-table.d.ts +3 -1
  201. package/lib/table/act-table.d.ts.map +1 -1
  202. package/lib/table/act-table.js +8 -7
  203. package/lib/table/act-table.js.map +1 -1
  204. package/lib/table/column/column-builder.d.ts.map +1 -1
  205. package/lib/table/column/column-builder.js +15 -6
  206. package/lib/table/column/column-builder.js.map +1 -1
  207. package/lib/table/column/index.less +85 -85
  208. package/lib/table/index.css +211 -211
  209. package/lib/table/modal-select-table.d.ts.map +1 -1
  210. package/lib/table/page-chart.js +1 -1
  211. package/lib/table/page-chart.js.map +1 -1
  212. package/lib/table/page-chart.less +9 -9
  213. package/lib/table/pagination.css +14 -14
  214. package/lib/table/pagination.d.ts.map +1 -1
  215. package/lib/table/relation-table.d.ts.map +1 -1
  216. package/lib/table/selected-rows-card.d.ts.map +1 -1
  217. package/lib/table/stat/restat.d.ts.map +1 -1
  218. package/lib/tmpl/interface.d.ts +4 -1
  219. package/lib/tmpl/interface.d.ts.map +1 -1
  220. package/lib/tmpl/interface.js.map +1 -1
  221. package/lib/tree/act-tree.d.ts.map +1 -1
  222. package/lib/tree/block-menu-auth-tree.d.ts.map +1 -1
  223. package/lib/tree/index.css +22 -22
  224. package/lib/tree/tmpl-tree.d.ts.map +1 -1
  225. package/lib/welcome/components/menu-card.less +96 -96
  226. package/lib/welcome/components/page-card.less +49 -49
  227. package/lib/welcome/components/quick-entrance.less +120 -120
  228. package/lib/welcome/components/user-menus.less +192 -192
  229. package/lib/welcome/components/workbench.less +118 -118
  230. package/lib/welcome/index.css +13 -13
  231. package/package.json +224 -224
  232. package/src/aldehyde/controls/2dEditor/2dEditor/index.less +5 -5
  233. package/src/aldehyde/controls/2dEditor/2dEditor/index.tsx +270 -270
  234. package/src/aldehyde/controls/2dEditor/2dView/index.less +8 -8
  235. package/src/aldehyde/controls/2dEditor/2dView/index.tsx +110 -110
  236. package/src/aldehyde/controls/2dEditor/components/card.tsx +256 -256
  237. package/src/aldehyde/controls/2dEditor/components/component.less +83 -83
  238. package/src/aldehyde/controls/2dEditor/components/data.d.ts +32 -32
  239. package/src/aldehyde/controls/2dEditor/components/hotspot.tsx +80 -80
  240. package/src/aldehyde/controls/2dEditor/components/html-box.tsx +101 -101
  241. package/src/aldehyde/controls/2dEditor/components/image.tsx +99 -99
  242. package/src/aldehyde/controls/2dEditor/components/line.tsx +73 -73
  243. package/src/aldehyde/controls/action/index.css +8 -8
  244. package/src/aldehyde/controls/action/index.tsx +406 -406
  245. package/src/aldehyde/controls/action/utils.tsx +306 -306
  246. package/src/aldehyde/controls/auto-complete/index.tsx +82 -82
  247. package/src/aldehyde/controls/cascader/index.tsx +112 -112
  248. package/src/aldehyde/controls/chemstruc/graph.tsx +185 -185
  249. package/src/aldehyde/controls/chemstruc/index.css +28 -28
  250. package/src/aldehyde/controls/code-editor/sql-code-editor.tsx +73 -73
  251. package/src/aldehyde/controls/collapse-card/index.css +8 -8
  252. package/src/aldehyde/controls/collapse-card/index.tsx +109 -109
  253. package/src/aldehyde/controls/color-picker/index.tsx +21 -21
  254. package/src/aldehyde/controls/counting-tag/index.tsx +53 -53
  255. package/src/aldehyde/controls/cquery/cquick-button.tsx +145 -145
  256. package/src/aldehyde/controls/date-picker/index.tsx +199 -199
  257. package/src/aldehyde/controls/direct-file-view/drawer-file-view.tsx +54 -54
  258. package/src/aldehyde/controls/direct-file-view/index.tsx +147 -147
  259. package/src/aldehyde/controls/direct-upload/index.tsx +140 -140
  260. package/src/aldehyde/controls/entity-select/entity-select.tsx +791 -791
  261. package/src/aldehyde/controls/entity-select/index.css +7 -7
  262. package/src/aldehyde/controls/entity-select/lab-tree-select.tsx +154 -154
  263. package/src/aldehyde/controls/entity-select/popover-entity-select.tsx +205 -205
  264. package/src/aldehyde/controls/entry-control.tsx +431 -431
  265. package/src/aldehyde/controls/enum-badge/index.tsx +42 -42
  266. package/src/aldehyde/controls/enum-tag/index.tsx +45 -45
  267. package/src/aldehyde/controls/field-history/index.tsx +81 -81
  268. package/src/aldehyde/controls/file-export/select-code-export.tsx +40 -40
  269. package/src/aldehyde/controls/file-view/drawer-file-view.tsx +117 -117
  270. package/src/aldehyde/controls/file-view/index.less +9 -9
  271. package/src/aldehyde/controls/file-view/index.tsx +148 -148
  272. package/src/aldehyde/controls/file-view/multi-file-view.tsx +39 -39
  273. package/src/aldehyde/controls/file-view/newin-file-view.tsx +40 -40
  274. package/src/aldehyde/controls/html-editor/draft.tsx +136 -136
  275. package/src/aldehyde/controls/html-editor/index.less +67 -67
  276. package/src/aldehyde/controls/icon-selector/app-icon-selector.tsx +68 -68
  277. package/src/aldehyde/controls/icon-selector/icon/aldehyde-menu-icon/iconfont.css +147 -147
  278. package/src/aldehyde/controls/icon-selector/icon/aldehyde-menu-icon/iconfont.json +240 -240
  279. package/src/aldehyde/controls/icon-selector/icon/phonenode-menu-icon/iconfont.css +63 -63
  280. package/src/aldehyde/controls/icon-selector/icon/phonenode-menu-icon/iconfont.json +93 -93
  281. package/src/aldehyde/controls/icon-selector/pc-icon-selector.tsx +68 -68
  282. package/src/aldehyde/controls/input-number/index.tsx +148 -148
  283. package/src/aldehyde/controls/input-range/index.tsx +59 -59
  284. package/src/aldehyde/controls/password-setter/index.css +2 -2
  285. package/src/aldehyde/controls/password-setter/index.js +88 -88
  286. package/src/aldehyde/controls/progress/index.tsx +74 -74
  287. package/src/aldehyde/controls/qr-code/index.less +28 -28
  288. package/src/aldehyde/controls/qr-code/index.tsx +40 -40
  289. package/src/aldehyde/controls/relation-existion/index.css +3 -3
  290. package/src/aldehyde/controls/relation-existion/index.tsx +144 -144
  291. package/src/aldehyde/controls/rfield/index.css +4 -4
  292. package/src/aldehyde/controls/rfield/index.tsx +225 -225
  293. package/src/aldehyde/controls/select/index.tsx +226 -226
  294. package/src/aldehyde/controls/signature/index.tsx +226 -226
  295. package/src/aldehyde/controls/single-checkbox/index.tsx +18 -18
  296. package/src/aldehyde/controls/steps/index.tsx +59 -59
  297. package/src/aldehyde/controls/text/ellipsis-text.tsx +98 -98
  298. package/src/aldehyde/controls/text/index.less +7 -7
  299. package/src/aldehyde/controls/tree-select/navigation-tree.tsx +122 -122
  300. package/src/aldehyde/controls/tree-select/tree-entity-select.tsx +121 -121
  301. package/src/aldehyde/controls/upload/index.tsx +128 -128
  302. package/src/aldehyde/controls/upload/mult-file-upload.tsx +240 -240
  303. package/src/aldehyde/controls/upload-read-excel/index.tsx +43 -43
  304. package/src/aldehyde/controls/view-control.tsx +289 -289
  305. package/src/aldehyde/custom-page/custom-detail-modal-page.tsx +69 -69
  306. package/src/aldehyde/custom-page/custom-page-router.tsx +64 -64
  307. package/src/aldehyde/custom-page/def-custom-page.tsx +17 -17
  308. package/src/aldehyde/custom-page/dtmpl-custom-edit-modal-page.tsx +91 -88
  309. package/src/aldehyde/detail/button/bottom-submit-button-bar.tsx +91 -91
  310. package/src/aldehyde/detail/button/cquery-button-bar.tsx +144 -144
  311. package/src/aldehyde/detail/button/edit-button.tsx +61 -61
  312. package/src/aldehyde/detail/button/fix-right-submit-button-bar.tsx +186 -186
  313. package/src/aldehyde/detail/button/index.css +42 -42
  314. package/src/aldehyde/detail/button/inline-edit-button.tsx +40 -40
  315. package/src/aldehyde/detail/button/submit-button-bar.tsx +57 -57
  316. package/src/aldehyde/detail/button/view-button.tsx +64 -64
  317. package/src/aldehyde/detail/dtmpl.css +72 -72
  318. package/src/aldehyde/detail/edit/dtmpl-edit.tsx +279 -279
  319. package/src/aldehyde/detail/edit/fields-edit-card.tsx +145 -145
  320. package/src/aldehyde/detail/edit/modal-row-edit.tsx +95 -95
  321. package/src/aldehyde/detail/edit/popover-edit-card.tsx +167 -167
  322. package/src/aldehyde/detail/edit/popover-editor.tsx +70 -70
  323. package/src/aldehyde/detail/edit/post-result/index.tsx +86 -86
  324. package/src/aldehyde/detail/rightbar/index.css +34 -34
  325. package/src/aldehyde/detail/rightbar/index.tsx +92 -92
  326. package/src/aldehyde/detail/tooltipbar/index.tsx +32 -32
  327. package/src/aldehyde/detail/view/act-dtmpl-view.tsx +288 -288
  328. package/src/aldehyde/detail/view/dtmpl-view.tsx +334 -334
  329. package/src/aldehyde/detail/view/field-view-group.tsx +88 -88
  330. package/src/aldehyde/detail/view/modal-dtmpl-view.tsx +73 -73
  331. package/src/aldehyde/detail/view/snapshot-timeline.tsx +231 -231
  332. package/src/aldehyde/detail/view/tab-act-dtmpl-view.tsx +304 -304
  333. package/src/aldehyde/detail/view/view-compare-panel.tsx +57 -57
  334. package/src/aldehyde/draw-canvas-edit/components/asset-bar/index.less +35 -35
  335. package/src/aldehyde/draw-canvas-edit/components/asset-bar/index.tsx +110 -110
  336. package/src/aldehyde/draw-canvas-edit/components/main-header/index.less +23 -23
  337. package/src/aldehyde/draw-canvas-edit/components/main-header/index.tsx +263 -263
  338. package/src/aldehyde/draw-canvas-edit/components/render/components/index.less +60 -60
  339. package/src/aldehyde/draw-canvas-edit/components/render/components/index.ts +3 -3
  340. package/src/aldehyde/draw-canvas-edit/components/render/components/workstation-component.tsx +220 -220
  341. package/src/aldehyde/draw-canvas-edit/components/render/draws/bg-draw.ts +177 -177
  342. package/src/aldehyde/draw-canvas-edit/components/render/draws/contextmenu-draw.ts +330 -330
  343. package/src/aldehyde/draw-canvas-edit/components/render/draws/graph-draw.ts +249 -249
  344. package/src/aldehyde/draw-canvas-edit/components/render/draws/index.ts +7 -7
  345. package/src/aldehyde/draw-canvas-edit/components/render/draws/link-draw.ts +1415 -1415
  346. package/src/aldehyde/draw-canvas-edit/components/render/draws/preview-draw.ts +274 -274
  347. package/src/aldehyde/draw-canvas-edit/components/render/draws/ref-line-draw.ts +71 -71
  348. package/src/aldehyde/draw-canvas-edit/components/render/draws/ruler-draw.ts +166 -166
  349. package/src/aldehyde/draw-canvas-edit/components/render/graphs/base-graph.ts +241 -241
  350. package/src/aldehyde/draw-canvas-edit/components/render/graphs/bezier.ts +542 -542
  351. package/src/aldehyde/draw-canvas-edit/components/render/graphs/circle.ts +699 -699
  352. package/src/aldehyde/draw-canvas-edit/components/render/graphs/curve.ts +500 -500
  353. package/src/aldehyde/draw-canvas-edit/components/render/graphs/index.ts +5 -5
  354. package/src/aldehyde/draw-canvas-edit/components/render/graphs/line.ts +493 -493
  355. package/src/aldehyde/draw-canvas-edit/components/render/graphs/rect.ts +680 -680
  356. package/src/aldehyde/draw-canvas-edit/components/render/handlers/drag-handlers.ts +68 -68
  357. package/src/aldehyde/draw-canvas-edit/components/render/handlers/drag-outside-handlers.ts +77 -77
  358. package/src/aldehyde/draw-canvas-edit/components/render/handlers/graph-handlers.ts +113 -113
  359. package/src/aldehyde/draw-canvas-edit/components/render/handlers/index.ts +9 -9
  360. package/src/aldehyde/draw-canvas-edit/components/render/handlers/key-move-handlers.ts +49 -49
  361. package/src/aldehyde/draw-canvas-edit/components/render/handlers/link-handlers.ts +45 -45
  362. package/src/aldehyde/draw-canvas-edit/components/render/handlers/selection-handlers.ts +410 -410
  363. package/src/aldehyde/draw-canvas-edit/components/render/handlers/shutcut-handlers.ts +45 -45
  364. package/src/aldehyde/draw-canvas-edit/components/render/handlers/text-handlers.ts +81 -81
  365. package/src/aldehyde/draw-canvas-edit/components/render/handlers/zoom-handlers.ts +59 -59
  366. package/src/aldehyde/draw-canvas-edit/components/render/index.ts +817 -817
  367. package/src/aldehyde/draw-canvas-edit/components/render/tools/align-tool.ts +89 -89
  368. package/src/aldehyde/draw-canvas-edit/components/render/tools/asset-tool.ts +154 -154
  369. package/src/aldehyde/draw-canvas-edit/components/render/tools/attract-tool.ts +457 -457
  370. package/src/aldehyde/draw-canvas-edit/components/render/tools/component-factory.ts +269 -269
  371. package/src/aldehyde/draw-canvas-edit/components/render/tools/copy-tool.ts +244 -244
  372. package/src/aldehyde/draw-canvas-edit/components/render/tools/import-export-tool.ts +588 -588
  373. package/src/aldehyde/draw-canvas-edit/components/render/tools/index.ts +10 -10
  374. package/src/aldehyde/draw-canvas-edit/components/render/tools/link-tool.ts +222 -222
  375. package/src/aldehyde/draw-canvas-edit/components/render/tools/position-tool.ts +191 -191
  376. package/src/aldehyde/draw-canvas-edit/components/render/tools/selection-tool.ts +140 -140
  377. package/src/aldehyde/draw-canvas-edit/components/render/tools/z-index-tool.ts +224 -224
  378. package/src/aldehyde/draw-canvas-edit/components/render/types.ts +298 -298
  379. package/src/aldehyde/draw-canvas-edit/components/render/utils/a-star.ts +116 -116
  380. package/src/aldehyde/draw-canvas-edit/components/render/utils/bezier-scene-func.ts +72 -72
  381. package/src/aldehyde/draw-canvas-edit/components/setting-form/imag-upload.tsx +119 -119
  382. package/src/aldehyde/draw-canvas-edit/components/setting-form/index.tsx +305 -305
  383. package/src/aldehyde/draw-canvas-edit/constant.ts +5 -5
  384. package/src/aldehyde/draw-canvas-edit/index.less +48 -48
  385. package/src/aldehyde/draw-canvas-edit/index.tsx +213 -213
  386. package/src/aldehyde/draw-canvas-view/index.less +66 -66
  387. package/src/aldehyde/draw-canvas-view/index.tsx +49 -49
  388. package/src/aldehyde/draw-canvas-view/view.tsx +237 -237
  389. package/src/aldehyde/export/export-frame.css +2 -2
  390. package/src/aldehyde/export/export-frame.tsx +301 -301
  391. package/src/aldehyde/export/select-code-export-frame.tsx +212 -212
  392. package/src/aldehyde/form/criteria-form.tsx +604 -604
  393. package/src/aldehyde/form/dtmpl-form.css +3 -3
  394. package/src/aldehyde/form/dtmpl-form.tsx +571 -571
  395. package/src/aldehyde/form/field-group-form.tsx +103 -103
  396. package/src/aldehyde/form/fields-form.tsx +45 -45
  397. package/src/aldehyde/form/form-Item-group.tsx +246 -246
  398. package/src/aldehyde/form/index.css +12 -12
  399. package/src/aldehyde/hooks/use-match-route/index.tsx +62 -62
  400. package/src/aldehyde/hooks/use-tabs/index.tsx +139 -139
  401. package/src/aldehyde/hooks/useVarCssColor.ts +6 -6
  402. package/src/aldehyde/icon/aliIcon.tsx +9 -9
  403. package/src/aldehyde/icon/index.tsx +28 -28
  404. package/src/aldehyde/import/excel-import.tsx +450 -450
  405. package/src/aldehyde/import/index.css +53 -53
  406. package/src/aldehyde/import/template.css +50 -50
  407. package/src/aldehyde/index.tsx +220 -220
  408. package/src/aldehyde/layout/MainPage.tsx +334 -334
  409. package/src/aldehyde/layout/common.css +64 -64
  410. package/src/aldehyde/layout/coverstyle.css +51 -51
  411. package/src/aldehyde/layout/footer/index.css +5 -5
  412. package/src/aldehyde/layout/footer/index.js +17 -17
  413. package/src/aldehyde/layout/header/index.css +122 -122
  414. package/src/aldehyde/layout/header/index.tsx +152 -152
  415. package/src/aldehyde/layout/menu/block.css +7 -7
  416. package/src/aldehyde/layout/menu/block.tsx +174 -174
  417. package/src/aldehyde/layout/menu/l2menu-message-bar.tsx +160 -160
  418. package/src/aldehyde/layout/menu/l2menu-quick-bar.tsx +175 -175
  419. package/src/aldehyde/layout/menu/menu-2layers.tsx +117 -117
  420. package/src/aldehyde/layout/menu/menu-render.tsx +168 -168
  421. package/src/aldehyde/layout/menu/message-bar.less +73 -73
  422. package/src/aldehyde/layout/menu/reset-password.tsx +255 -255
  423. package/src/aldehyde/layout/menu/user-bar.tsx +259 -259
  424. package/src/aldehyde/layout/menu/userinfo-bar.tsx +69 -69
  425. package/src/aldehyde/layout/sidebar/index.css +57 -57
  426. package/src/aldehyde/layout/sidebar/index.tsx +84 -84
  427. package/src/aldehyde/layout2/components/icon-font.tsx +7 -7
  428. package/src/aldehyde/layout2/components/screenfull-button.tsx +21 -21
  429. package/src/aldehyde/layout2/components/search-menu.tsx +85 -85
  430. package/src/aldehyde/layout2/components/system-messages.tsx +75 -75
  431. package/src/aldehyde/layout2/components/theme-button.tsx +65 -65
  432. package/src/aldehyde/layout2/components/user-button.tsx +258 -258
  433. package/src/aldehyde/layout2/components/user-notification.tsx +74 -74
  434. package/src/aldehyde/layout2/css/header.css +41 -41
  435. package/src/aldehyde/layout2/css/sider.less +17 -17
  436. package/src/aldehyde/layout2/css/tabs-layout.less +18 -18
  437. package/src/aldehyde/layout2/header.tsx +278 -278
  438. package/src/aldehyde/layout2/layout-context.tsx +95 -95
  439. package/src/aldehyde/layout2/main.tsx +30 -30
  440. package/src/aldehyde/layout2/page.tsx +315 -315
  441. package/src/aldehyde/layout2/sider.tsx +230 -230
  442. package/src/aldehyde/layout2/tabs/tabs-context.tsx +37 -37
  443. package/src/aldehyde/layout2/tabs/tabs-layout.tsx +146 -146
  444. package/src/aldehyde/layout2/type/layout-type.ts +15 -15
  445. package/src/aldehyde/layout2/util/menu-util.tsx +125 -125
  446. package/src/aldehyde/layout3/components/tabs-layout.tsx +110 -110
  447. package/src/aldehyde/layout3/components/time.tsx +25 -25
  448. package/src/aldehyde/layout3/css/header.less +195 -195
  449. package/src/aldehyde/layout3/css/main.less +161 -161
  450. package/src/aldehyde/layout3/css/sider.less +32 -32
  451. package/src/aldehyde/layout3/css/tabs-layout.less +38 -38
  452. package/src/aldehyde/layout3/header.tsx +187 -187
  453. package/src/aldehyde/layout3/main.tsx +29 -29
  454. package/src/aldehyde/layout3/page.tsx +110 -110
  455. package/src/aldehyde/layout3/sider.tsx +198 -198
  456. package/src/aldehyde/layout4/components/tabs-layout.tsx +110 -110
  457. package/src/aldehyde/layout4/css/header.less +196 -196
  458. package/src/aldehyde/layout4/css/main.less +154 -154
  459. package/src/aldehyde/layout4/css/sider.less +37 -37
  460. package/src/aldehyde/layout4/css/tabs-layout.less +42 -42
  461. package/src/aldehyde/layout4/header.tsx +190 -190
  462. package/src/aldehyde/layout4/imgs/user.svg +26 -26
  463. package/src/aldehyde/layout4/main.tsx +29 -29
  464. package/src/aldehyde/layout4/page.tsx +125 -125
  465. package/src/aldehyde/layout4/sider.tsx +201 -201
  466. package/src/aldehyde/layout5/css/header.less +35 -35
  467. package/src/aldehyde/layout5/css/sider.less +18 -18
  468. package/src/aldehyde/layout5/header.tsx +204 -204
  469. package/src/aldehyde/layout5/page.tsx +107 -107
  470. package/src/aldehyde/layout5/sider.tsx +235 -235
  471. package/src/aldehyde/list/calendar/index.less +20 -20
  472. package/src/aldehyde/list/calendar/index.tsx +157 -157
  473. package/src/aldehyde/list/card-list/card-list-item.tsx +112 -112
  474. package/src/aldehyde/list/card-list/index.less +154 -154
  475. package/src/aldehyde/list/card-list/index.tsx +83 -83
  476. package/src/aldehyde/list/gantt/index.less +8 -8
  477. package/src/aldehyde/list/gantt/index.tsx +508 -508
  478. package/src/aldehyde/list/vertical-list/index.less +208 -208
  479. package/src/aldehyde/list/vertical-list/index.tsx +55 -55
  480. package/src/aldehyde/list/vertical-list/item.tsx +136 -136
  481. package/src/aldehyde/locale/LocaleButton.tsx +48 -48
  482. package/src/aldehyde/locale/LocaleProvider.tsx +265 -265
  483. package/src/aldehyde/locale/langMp.ts +45 -45
  484. package/src/aldehyde/locale/translate.ts +80 -80
  485. package/src/aldehyde/locale/useLocale.ts +72 -72
  486. package/src/aldehyde/login/context-setter.tsx +130 -130
  487. package/src/aldehyde/login/index.css +19 -19
  488. package/src/aldehyde/login/login.tsx +255 -255
  489. package/src/aldehyde/login/router-login.tsx +107 -107
  490. package/src/aldehyde/login/vertify/index.css +143 -143
  491. package/src/aldehyde/login/vertify/index.tsx +360 -360
  492. package/src/aldehyde/login/vertify/tool.ts +13 -13
  493. package/src/aldehyde/login2/login-page.tsx +92 -92
  494. package/src/aldehyde/login2/login.tsx +227 -227
  495. package/src/aldehyde/login3/index.less +136 -136
  496. package/src/aldehyde/login3/login-page.tsx +71 -71
  497. package/src/aldehyde/lowcode-components/act-table/index.less +26 -26
  498. package/src/aldehyde/lowcode-components/act-table/index.tsx +139 -139
  499. package/src/aldehyde/lowcode-components/assets/lowcode-constant.tsx +12 -12
  500. package/src/aldehyde/lowcode-components/bar-chart/index.tsx +272 -272
  501. package/src/aldehyde/lowcode-components/base-button/index.less +7 -7
  502. package/src/aldehyde/lowcode-components/base-button/index.tsx +197 -197
  503. package/src/aldehyde/lowcode-components/base-color-block/index.tsx +31 -31
  504. package/src/aldehyde/lowcode-components/base-image/index.tsx +220 -220
  505. package/src/aldehyde/lowcode-components/base-map/index.tsx +292 -292
  506. package/src/aldehyde/lowcode-components/base-radio/index.less +23 -23
  507. package/src/aldehyde/lowcode-components/base-radio/index.tsx +157 -157
  508. package/src/aldehyde/lowcode-components/base-table/index.less +61 -61
  509. package/src/aldehyde/lowcode-components/base-table/index.tsx +268 -268
  510. package/src/aldehyde/lowcode-components/base-tabs/index.less +14 -14
  511. package/src/aldehyde/lowcode-components/base-tabs/index.tsx +183 -183
  512. package/src/aldehyde/lowcode-components/base-text/index.less +19 -19
  513. package/src/aldehyde/lowcode-components/base-text/index.tsx +58 -58
  514. package/src/aldehyde/lowcode-components/border/border1/index.tsx +70 -70
  515. package/src/aldehyde/lowcode-components/border/border10/index.less +26 -26
  516. package/src/aldehyde/lowcode-components/border/border10/index.tsx +45 -45
  517. package/src/aldehyde/lowcode-components/border/border11/index.less +17 -17
  518. package/src/aldehyde/lowcode-components/border/border11/index.tsx +232 -232
  519. package/src/aldehyde/lowcode-components/border/border12/index.less +13 -13
  520. package/src/aldehyde/lowcode-components/border/border12/index.tsx +115 -115
  521. package/src/aldehyde/lowcode-components/border/border13/index.less +13 -13
  522. package/src/aldehyde/lowcode-components/border/border13/index.tsx +69 -69
  523. package/src/aldehyde/lowcode-components/border/border2/index.less +17 -17
  524. package/src/aldehyde/lowcode-components/border/border2/index.tsx +51 -51
  525. package/src/aldehyde/lowcode-components/border/border3/index.less +25 -25
  526. package/src/aldehyde/lowcode-components/border/border3/index.tsx +61 -61
  527. package/src/aldehyde/lowcode-components/border/border4/index.less +72 -72
  528. package/src/aldehyde/lowcode-components/border/border4/index.tsx +79 -79
  529. package/src/aldehyde/lowcode-components/border/border5/index.less +35 -35
  530. package/src/aldehyde/lowcode-components/border/border5/index.tsx +75 -75
  531. package/src/aldehyde/lowcode-components/border/border6/index.less +17 -17
  532. package/src/aldehyde/lowcode-components/border/border6/index.tsx +60 -60
  533. package/src/aldehyde/lowcode-components/border/border7/index.less +26 -26
  534. package/src/aldehyde/lowcode-components/border/border7/index.tsx +75 -75
  535. package/src/aldehyde/lowcode-components/border/border8/index.less +13 -13
  536. package/src/aldehyde/lowcode-components/border/border8/index.tsx +84 -84
  537. package/src/aldehyde/lowcode-components/border/border9/index.less +13 -13
  538. package/src/aldehyde/lowcode-components/border/border9/index.tsx +154 -154
  539. package/src/aldehyde/lowcode-components/capsule-bar-chart/index.tsx +290 -290
  540. package/src/aldehyde/lowcode-components/carousel/index.tsx +218 -218
  541. package/src/aldehyde/lowcode-components/circular-progress-chart/index.tsx +263 -263
  542. package/src/aldehyde/lowcode-components/column-3d-chart/index.tsx +442 -442
  543. package/src/aldehyde/lowcode-components/column-chart/index.tsx +349 -297
  544. package/src/aldehyde/lowcode-components/data-number/index.less +10 -10
  545. package/src/aldehyde/lowcode-components/data-number/index.tsx +219 -219
  546. package/src/aldehyde/lowcode-components/data.d.ts +19 -19
  547. package/src/aldehyde/lowcode-components/date-time/index.less +4 -4
  548. package/src/aldehyde/lowcode-components/date-time/index.tsx +64 -64
  549. package/src/aldehyde/lowcode-components/decoration/decoration1/index.less +7 -7
  550. package/src/aldehyde/lowcode-components/decoration/decoration1/index.tsx +153 -153
  551. package/src/aldehyde/lowcode-components/decoration/decoration10/index.less +5 -5
  552. package/src/aldehyde/lowcode-components/decoration/decoration10/index.tsx +89 -89
  553. package/src/aldehyde/lowcode-components/decoration/decoration11/index.less +5 -5
  554. package/src/aldehyde/lowcode-components/decoration/decoration11/index.tsx +133 -133
  555. package/src/aldehyde/lowcode-components/decoration/decoration2/index.less +6 -6
  556. package/src/aldehyde/lowcode-components/decoration/decoration2/index.tsx +61 -61
  557. package/src/aldehyde/lowcode-components/decoration/decoration3/index.less +7 -7
  558. package/src/aldehyde/lowcode-components/decoration/decoration3/index.tsx +87 -87
  559. package/src/aldehyde/lowcode-components/decoration/decoration4/index.less +29 -29
  560. package/src/aldehyde/lowcode-components/decoration/decoration4/index.tsx +53 -53
  561. package/src/aldehyde/lowcode-components/decoration/decoration5/index.less +3 -3
  562. package/src/aldehyde/lowcode-components/decoration/decoration5/index.tsx +116 -116
  563. package/src/aldehyde/lowcode-components/decoration/decoration6/index.less +7 -7
  564. package/src/aldehyde/lowcode-components/decoration/decoration6/index.tsx +121 -121
  565. package/src/aldehyde/lowcode-components/decoration/decoration7/index.less +4 -4
  566. package/src/aldehyde/lowcode-components/decoration/decoration7/index.tsx +70 -70
  567. package/src/aldehyde/lowcode-components/decoration/decoration8/index.less +14 -14
  568. package/src/aldehyde/lowcode-components/decoration/decoration8/index.tsx +122 -122
  569. package/src/aldehyde/lowcode-components/decoration/decoration9/index.less +4 -4
  570. package/src/aldehyde/lowcode-components/decoration/decoration9/index.tsx +196 -196
  571. package/src/aldehyde/lowcode-components/effectScatter-map/index.tsx +315 -315
  572. package/src/aldehyde/lowcode-components/effectScatter-map-3d/index.tsx +419 -419
  573. package/src/aldehyde/lowcode-components/four-angle-glow-border/index.less +49 -49
  574. package/src/aldehyde/lowcode-components/four-angle-glow-border/index.tsx +53 -53
  575. package/src/aldehyde/lowcode-components/gauge-chart/index.tsx +254 -254
  576. package/src/aldehyde/lowcode-components/index.ts +130 -130
  577. package/src/aldehyde/lowcode-components/line-bar-chart/index.tsx +356 -304
  578. package/src/aldehyde/lowcode-components/line-chart/index.tsx +346 -294
  579. package/src/aldehyde/lowcode-components/liquid-chart/index.tsx +250 -250
  580. package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-controller.ts +64 -64
  581. package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-definition.ts +77 -77
  582. package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-designer-loader.ts +36 -36
  583. package/src/aldehyde/lowcode-components/lowcode-view/component/assets.ts +478 -478
  584. package/src/aldehyde/lowcode-components/lowcode-view/component/component-container.tsx +91 -91
  585. package/src/aldehyde/lowcode-components/lowcode-view/component/component-controller.ts +153 -153
  586. package/src/aldehyde/lowcode-components/lowcode-view/component/component-definition.ts +23 -23
  587. package/src/aldehyde/lowcode-components/lowcode-view/component/font/FontGlobal.css +26 -26
  588. package/src/aldehyde/lowcode-components/lowcode-view/component/group-layer/controller.ts +36 -36
  589. package/src/aldehyde/lowcode-components/lowcode-view/component/group-layer/definition.ts +53 -53
  590. package/src/aldehyde/lowcode-components/lowcode-view/component/group-layer/index.tsx +15 -15
  591. package/src/aldehyde/lowcode-components/lowcode-view/component/layer-builder.tsx +98 -98
  592. package/src/aldehyde/lowcode-components/lowcode-view/component/loading.tsx +20 -20
  593. package/src/aldehyde/lowcode-components/lowcode-view/component/screen-fit/index.less +13 -13
  594. package/src/aldehyde/lowcode-components/lowcode-view/component/screen-fit/index.tsx +121 -121
  595. package/src/aldehyde/lowcode-components/lowcode-view/component/util.ts +27 -27
  596. package/src/aldehyde/lowcode-components/lowcode-view/index.less +19 -19
  597. package/src/aldehyde/lowcode-components/lowcode-view/index.tsx +279 -277
  598. package/src/aldehyde/lowcode-components/lowcode-view/interface.ts +189 -189
  599. package/src/aldehyde/lowcode-components/pie-chart/index.tsx +353 -353
  600. package/src/aldehyde/lowcode-components/placeholder-component/index.tsx +81 -81
  601. package/src/aldehyde/lowcode-components/progress-chart/index.tsx +295 -295
  602. package/src/aldehyde/lowcode-components/radar-chart/index.tsx +322 -322
  603. package/src/aldehyde/lowcode-components/search-form/index.less +25 -25
  604. package/src/aldehyde/lowcode-components/search-form/index.tsx +121 -121
  605. package/src/aldehyde/lowcode-components/stroke-animation/index.tsx +219 -219
  606. package/src/aldehyde/lowcode-components/text-scroller/index.less +28 -28
  607. package/src/aldehyde/lowcode-components/text-scroller/index.tsx +173 -173
  608. package/src/aldehyde/module/block-menu-tree-drawer.tsx +118 -118
  609. package/src/aldehyde/module/criteria-page.tsx1 +175 -175
  610. package/src/aldehyde/module/draggable-modal.tsx +66 -66
  611. package/src/aldehyde/module/dtmpl-edit-card.tsx +479 -477
  612. package/src/aldehyde/module/dtmpl-edit-drawer.tsx +24 -23
  613. package/src/aldehyde/module/dtmpl-edit-modal.tsx +26 -25
  614. package/src/aldehyde/module/dtmpl-edit-page.tsx +600 -597
  615. package/src/aldehyde/module/dtmpl-editor.tsx +165 -165
  616. package/src/aldehyde/module/dtmpl-view-card.tsx +64 -64
  617. package/src/aldehyde/module/dtmpl-view-drawer.tsx +71 -71
  618. package/src/aldehyde/module/dtmpl-view-modal.tsx +56 -56
  619. package/src/aldehyde/module/embed-dtmpl-edit-page.tsx +137 -137
  620. package/src/aldehyde/module/index.less +4 -4
  621. package/src/aldehyde/module/ltmpl-drawer.tsx +60 -60
  622. package/src/aldehyde/module/ltmpl-modal.tsx +63 -63
  623. package/src/aldehyde/module/ltmpl-table.tsx +388 -379
  624. package/src/aldehyde/module/ttmpl-tree.tsx +47 -47
  625. package/src/aldehyde/routable/dtmpl-route.tsx +173 -173
  626. package/src/aldehyde/routable/import-route.tsx +35 -35
  627. package/src/aldehyde/routable/index.less +25 -25
  628. package/src/aldehyde/routable/ltmpl-route.tsx +544 -539
  629. package/src/aldehyde/routable/splitview-ltmpl-route.tsx +382 -377
  630. package/src/aldehyde/routable/ttmpl-route.tsx +93 -93
  631. package/src/aldehyde/routable/withroute.tsx +36 -36
  632. package/src/aldehyde/sso-Login/index.tsx +73 -73
  633. package/src/aldehyde/sso-Login/service/index.js +16 -16
  634. package/src/aldehyde/sso-Login/service/login.js +75 -75
  635. package/src/aldehyde/table/act-table.tsx +1846 -1844
  636. package/src/aldehyde/table/column/column-builder.tsx +882 -876
  637. package/src/aldehyde/table/column/column-selector.tsx +130 -130
  638. package/src/aldehyde/table/column/index.less +85 -85
  639. package/src/aldehyde/table/column/summary-builder.tsx +712 -712
  640. package/src/aldehyde/table/column/theme-color-getter.tsx +25 -25
  641. package/src/aldehyde/table/control-table-x-axis-wrapper.tsx +80 -80
  642. package/src/aldehyde/table/index.css +211 -211
  643. package/src/aldehyde/table/l2-act-table.tsx +91 -91
  644. package/src/aldehyde/table/modal-select-table.tsx +308 -308
  645. package/src/aldehyde/table/page-chart.less +9 -9
  646. package/src/aldehyde/table/page-chart.tsx +196 -196
  647. package/src/aldehyde/table/page-config-button.tsx +203 -203
  648. package/src/aldehyde/table/pagination.css +14 -14
  649. package/src/aldehyde/table/pagination.tsx +81 -81
  650. package/src/aldehyde/table/query-table.tsx +668 -668
  651. package/src/aldehyde/table/relation-table.tsx +1078 -1078
  652. package/src/aldehyde/table/report-table.tsx +125 -125
  653. package/src/aldehyde/table/resizable-table.tsx +97 -97
  654. package/src/aldehyde/table/row-table.tsx +22 -22
  655. package/src/aldehyde/table/select-table.tsx +559 -559
  656. package/src/aldehyde/table/selected-rows-card.tsx +78 -78
  657. package/src/aldehyde/table/stat/restat.tsx +122 -122
  658. package/src/aldehyde/table/table-util.tsx +25 -25
  659. package/src/aldehyde/tmpl/control-type-supportor.tsx +154 -154
  660. package/src/aldehyde/tmpl/hc-data-source.tsx +574 -574
  661. package/src/aldehyde/tmpl/hcservice-v3.tsx +1590 -1590
  662. package/src/aldehyde/tmpl/interface.tsx +939 -936
  663. package/src/aldehyde/tmpl/model-struc-v3.tsx +111 -111
  664. package/src/aldehyde/tmpl/superagent.js +146 -146
  665. package/src/aldehyde/tmpl/tmpl-config-analysis.tsx +585 -585
  666. package/src/aldehyde/tmpl/web-socket.ts +366 -366
  667. package/src/aldehyde/tree/act-tree.tsx +217 -217
  668. package/src/aldehyde/tree/block-menu-auth-tree.tsx +189 -189
  669. package/src/aldehyde/tree/index.css +22 -22
  670. package/src/aldehyde/tree/navigation-tree.tsx +39 -39
  671. package/src/aldehyde/tree/tmpl-tree.tsx +751 -751
  672. package/src/aldehyde/tree/tree-node.tsx +73 -73
  673. package/src/aldehyde/tree/tree-utils.tsx +317 -317
  674. package/src/aldehyde/units/EncryptUtils.js +37 -37
  675. package/src/aldehyde/units/image.d.ts +7 -7
  676. package/src/aldehyde/units/index.tsx +1367 -1367
  677. package/src/aldehyde/units/storage.js +2 -2
  678. package/src/aldehyde/utils/dsu.ts +27 -27
  679. package/src/aldehyde/welcome/HCWelcome.js +404 -404
  680. package/src/aldehyde/welcome/HCWelcome1.js +259 -259
  681. package/src/aldehyde/welcome/components/menu-card.less +96 -96
  682. package/src/aldehyde/welcome/components/menu-card.tsx +70 -70
  683. package/src/aldehyde/welcome/components/page-card.less +49 -49
  684. package/src/aldehyde/welcome/components/page-card.tsx +97 -97
  685. package/src/aldehyde/welcome/components/quick-entrance.less +120 -120
  686. package/src/aldehyde/welcome/components/quick-entrance.tsx +80 -80
  687. package/src/aldehyde/welcome/components/user-menus.less +192 -192
  688. package/src/aldehyde/welcome/components/user-menus.tsx +279 -279
  689. package/src/aldehyde/welcome/components/workbench.less +118 -118
  690. package/src/aldehyde/welcome/components/workbench.tsx +146 -146
  691. package/src/aldehyde/welcome/index.css +13 -13
@@ -1,1415 +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
- 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
- }
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
+ }