@jnrs/lingshu-smart 2.2.8 → 2.2.9

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 (176) hide show
  1. package/dist/App.vue.d.ts +1 -2
  2. package/dist/assets/data/editor_default_setting.d.ts +1 -8
  3. package/dist/assets/data/editor_preset_menu.d.ts +1 -8
  4. package/dist/components/editor/ControlBar/CaseManger.vue.d.ts +15 -3
  5. package/dist/components/editor/ControlBar/CaseTitleEdit.vue.d.ts +411 -2
  6. package/dist/components/editor/ControlBar/ExportImportDialog.vue.d.ts +2 -3
  7. package/dist/components/editor/ControlBar/MainButton.vue.d.ts +2 -3
  8. package/dist/components/editor/ControlBar/StepButton.vue.d.ts +1 -2
  9. package/dist/components/editor/ControlBar/StepRecordVisualizer.vue.d.ts +1 -2
  10. package/dist/components/editor/DrawingBoard.vue.d.ts +1 -2
  11. package/dist/components/editor/MenuCard/Equipments.vue.d.ts +1 -2
  12. package/dist/components/editor/MenuCard/Layers.vue.d.ts +1 -2
  13. package/dist/components/editor/MenuCard/index.vue.d.ts +1 -2
  14. package/dist/components/editor/OptionCard/Equipment/Base.vue.d.ts +1 -2
  15. package/dist/components/editor/OptionCard/Equipment/DataSets.vue.d.ts +1 -2
  16. package/dist/components/editor/OptionCard/Equipment/Interaction.vue.d.ts +1 -2
  17. package/dist/components/editor/OptionCard/Equipment/Position.vue.d.ts +1 -2
  18. package/dist/components/editor/OptionCard/Equipment/StationSlotGroup.vue.d.ts +1 -2
  19. package/dist/components/editor/OptionCard/Equipment/index.vue.d.ts +1 -2
  20. package/dist/components/editor/OptionCard/Equipment/models/MachineTool.vue.d.ts +1 -2
  21. package/dist/components/editor/OptionCard/Equipment/models/Rail.vue.d.ts +1 -2
  22. package/dist/components/editor/OptionCard/Equipment/models/SingleJointRobot.vue.d.ts +2 -0
  23. package/dist/components/editor/OptionCard/Scene/Background.vue.d.ts +1 -2
  24. package/dist/components/editor/OptionCard/Scene/index.vue.d.ts +1 -2
  25. package/dist/components/editor/OptionCard/index.vue.d.ts +1 -2
  26. package/dist/components/editor/index.vue.d.ts +13 -4
  27. package/dist/components/index.d.ts +2 -2
  28. package/dist/components/index.js +27281 -4
  29. package/dist/components/preview/index.vue.d.ts +5 -6
  30. package/dist/composables/useStepRecord.d.ts +4 -12
  31. package/dist/constants/options.d.ts +1 -8
  32. package/dist/controller/AppController.d.ts +3 -10
  33. package/dist/controller/EditorController.d.ts +2 -9
  34. package/dist/index.js +1 -1
  35. package/dist/json/cases.json +577 -20
  36. package/dist/locales/i18next.d.ts +1 -1
  37. package/dist/locales/index.d.ts +2 -2
  38. package/dist/locales/index.js +13 -3
  39. package/dist/main.d.ts +0 -3
  40. package/dist/playground/EditPageDemo.vue.d.ts +1 -2
  41. package/dist/playground/ViewPageDemo.vue.d.ts +27 -2
  42. package/dist/stores/useAppStore.d.ts +5 -12
  43. package/dist/stores/useDataStore.d.ts +11 -18
  44. package/dist/stores/useEditorStore.d.ts +20 -27
  45. package/dist/types/app.types.d.ts +1 -1
  46. package/dist/types/base.types.d.ts +1 -1
  47. package/dist/types/components/config.types.d.ts +1 -1
  48. package/dist/types/components/operating.types.d.ts +1 -1
  49. package/dist/types/enums.d.ts +1 -1
  50. package/dist/types/guards.d.ts +5 -12
  51. package/dist/types/index.d.ts +2 -2
  52. package/dist/types/models/config.types.d.ts +49 -47
  53. package/dist/types/models/operating.types.d.ts +53 -53
  54. package/dist/ui/abstract/ComponentAbs.d.ts +2 -9
  55. package/dist/ui/abstract/ModelAbs.d.ts +2 -10
  56. package/dist/ui/components/Entrance.d.ts +1 -8
  57. package/dist/ui/components/Light.d.ts +1 -8
  58. package/dist/ui/components/Progress.d.ts +1 -8
  59. package/dist/ui/components/Resource.d.ts +1 -8
  60. package/dist/ui/components/StationSlot.d.ts +1 -23
  61. package/dist/ui/components/StationSlotGroup.d.ts +1 -8
  62. package/dist/ui/factories/createGlass.d.ts +0 -6
  63. package/dist/ui/factories/createModel.d.ts +2 -9
  64. package/dist/ui/factories/createShadow.d.ts +1 -9
  65. package/dist/ui/factories/createText.d.ts +0 -7
  66. package/dist/ui/models/CleaningMachine.d.ts +1 -1
  67. package/dist/ui/models/DoubleJointRobot.d.ts +19 -20
  68. package/dist/ui/models/LoadingStation.d.ts +1 -1
  69. package/dist/ui/models/MachineTool.d.ts +1 -1
  70. package/dist/ui/models/MarkingMachine.d.ts +1 -1
  71. package/dist/ui/models/Rail.d.ts +1 -1
  72. package/dist/ui/models/ResourceStore.d.ts +1 -1
  73. package/dist/ui/models/SingleJointRobot.d.ts +3 -3
  74. package/dist/ui/shapes/NamePlate.d.ts +0 -7
  75. package/dist/ui/shapes/ScrewHole.d.ts +0 -7
  76. package/dist/ui/shapes/Texture.d.ts +1 -8
  77. package/dist/ui/utils/attr.d.ts +2 -9
  78. package/dist/utils/type-guards.d.ts +1 -1
  79. package/package.json +3 -3
  80. package/dist/App.vue.js +0 -30
  81. package/dist/assets/data/editor_default.d.ts +0 -16
  82. package/dist/assets/data/editor_default.js +0 -59
  83. package/dist/assets/data/editor_default_setting.js +0 -58
  84. package/dist/assets/data/editor_preset.d.ts +0 -9
  85. package/dist/assets/data/editor_preset.js +0 -51
  86. package/dist/assets/data/editor_preset_menu.js +0 -290
  87. package/dist/components/editor/ControlBar/CaseManger.vue.js +0 -465
  88. package/dist/components/editor/ControlBar/CaseTitleEdit.vue.js +0 -108
  89. package/dist/components/editor/ControlBar/ExportImportDialog.vue.js +0 -280
  90. package/dist/components/editor/ControlBar/MainButton.vue.js +0 -183
  91. package/dist/components/editor/ControlBar/StepButton.vue.js +0 -147
  92. package/dist/components/editor/ControlBar/StepRecordVisualizer.vue.js +0 -98
  93. package/dist/components/editor/DrawingBoard.vue.js +0 -31
  94. package/dist/components/editor/MenuCard/Equipments.vue.js +0 -129
  95. package/dist/components/editor/MenuCard/Layers.vue.js +0 -201
  96. package/dist/components/editor/MenuCard/index.vue.js +0 -84
  97. package/dist/components/editor/OptionCard/Equipment/Base.vue.js +0 -96
  98. package/dist/components/editor/OptionCard/Equipment/Binds.vue.d.ts +0 -3
  99. package/dist/components/editor/OptionCard/Equipment/Binds.vue.js +0 -443
  100. package/dist/components/editor/OptionCard/Equipment/Bot.vue.d.ts +0 -3
  101. package/dist/components/editor/OptionCard/Equipment/Bot.vue.js +0 -81
  102. package/dist/components/editor/OptionCard/Equipment/DataSets.vue.js +0 -304
  103. package/dist/components/editor/OptionCard/Equipment/DockStore.vue.d.ts +0 -3
  104. package/dist/components/editor/OptionCard/Equipment/DockStore.vue.js +0 -597
  105. package/dist/components/editor/OptionCard/Equipment/Interaction.vue.js +0 -287
  106. package/dist/components/editor/OptionCard/Equipment/Position.backup.vue.d.ts +0 -3
  107. package/dist/components/editor/OptionCard/Equipment/Position.backup.vue.js +0 -440
  108. package/dist/components/editor/OptionCard/Equipment/Position.vue.js +0 -436
  109. package/dist/components/editor/OptionCard/Equipment/StationSlotGroup.vue.js +0 -1131
  110. package/dist/components/editor/OptionCard/Equipment/Store.vue.d.ts +0 -3
  111. package/dist/components/editor/OptionCard/Equipment/Store.vue.js +0 -453
  112. package/dist/components/editor/OptionCard/Equipment/Trailer.vue.d.ts +0 -3
  113. package/dist/components/editor/OptionCard/Equipment/Trailer.vue.js +0 -1109
  114. package/dist/components/editor/OptionCard/Equipment/index.vue.js +0 -100
  115. package/dist/components/editor/OptionCard/Equipment/models/MachineTool.vue.js +0 -99
  116. package/dist/components/editor/OptionCard/Equipment/models/Rail.vue.js +0 -225
  117. package/dist/components/editor/OptionCard/Equipment/models/SingleGripperRobot.vue.d.ts +0 -3
  118. package/dist/components/editor/OptionCard/Equipment/models/SingleGripperRobot.vue.js +0 -99
  119. package/dist/components/editor/OptionCard/Scene/Background.vue.js +0 -543
  120. package/dist/components/editor/OptionCard/Scene/index.vue.js +0 -200
  121. package/dist/components/editor/OptionCard/index.vue.js +0 -73
  122. package/dist/components/editor/index.vue.js +0 -156
  123. package/dist/components/preview/index.vue.js +0 -104
  124. package/dist/composables/useStepRecord.js +0 -135
  125. package/dist/constants/options.js +0 -55
  126. package/dist/controller/AppController.js +0 -168
  127. package/dist/controller/EditorController.js +0 -173
  128. package/dist/locales/en.js +0 -5
  129. package/dist/locales/i18next.js +0 -6
  130. package/dist/locales/zhCn.js +0 -5
  131. package/dist/main.js +0 -13
  132. package/dist/playground/EditPageDemo.vue.js +0 -57
  133. package/dist/playground/ViewPageDemo.vue.js +0 -277
  134. package/dist/stores/index.js +0 -3
  135. package/dist/stores/useAppStore.js +0 -78
  136. package/dist/stores/useDataStore.js +0 -116
  137. package/dist/stores/useEditorStore.js +0 -263
  138. package/dist/types/app.types.js +0 -2
  139. package/dist/types/base.types.js +0 -1
  140. package/dist/types/components/config.types.js +0 -1
  141. package/dist/types/components/operating.types.js +0 -1
  142. package/dist/types/enums.js +0 -46
  143. package/dist/types/guards.js +0 -28
  144. package/dist/types/index.js +0 -8
  145. package/dist/types/models/config.types.js +0 -1
  146. package/dist/types/models/operating.types.js +0 -1
  147. package/dist/ui/abstract/ComponentAbs.js +0 -64
  148. package/dist/ui/abstract/ModelAbs.js +0 -119
  149. package/dist/ui/components/Entrance.js +0 -83
  150. package/dist/ui/components/Light.js +0 -167
  151. package/dist/ui/components/Progress.js +0 -84
  152. package/dist/ui/components/Resource.js +0 -70
  153. package/dist/ui/components/StationSlot.js +0 -207
  154. package/dist/ui/components/StationSlotGroup.js +0 -110
  155. package/dist/ui/factories/createGlass.js +0 -51
  156. package/dist/ui/factories/createModel.js +0 -35
  157. package/dist/ui/factories/createShadow.js +0 -52
  158. package/dist/ui/factories/createText.js +0 -46
  159. package/dist/ui/models/CleaningMachine.js +0 -141
  160. package/dist/ui/models/DoubleJointRobot.js +0 -545
  161. package/dist/ui/models/LoadingStation.js +0 -167
  162. package/dist/ui/models/MachineTool.js +0 -184
  163. package/dist/ui/models/MarkingMachine.js +0 -148
  164. package/dist/ui/models/Rail.js +0 -117
  165. package/dist/ui/models/ResourceStore.js +0 -101
  166. package/dist/ui/models/SingleBot.d.ts +0 -20
  167. package/dist/ui/models/SingleBot.js +0 -202
  168. package/dist/ui/models/SingleGripperRobot.d.ts +0 -19
  169. package/dist/ui/models/SingleGripperRobot.js +0 -272
  170. package/dist/ui/models/SingleJointRobot.js +0 -346
  171. package/dist/ui/shapes/NamePlate.js +0 -85
  172. package/dist/ui/shapes/ScrewHole.js +0 -57
  173. package/dist/ui/shapes/Texture.js +0 -51
  174. package/dist/ui/utils/attr.js +0 -50
  175. package/dist/utils/index.js +0 -92
  176. package/dist/utils/type-guards.js +0 -105
@@ -1,346 +0,0 @@
1
- import { EnumResourceType } from '@/types';
2
- import { Box, Group } from 'leafer';
3
- import { ModelAbs } from '../abstract/ModelAbs';
4
- import { StationSlot } from '../components/StationSlot';
5
- import { setCursor } from '../utils/attr';
6
- import { createShadow } from '../factories/createShadow';
7
- import { ScrewHole } from '../shapes/ScrewHole';
8
- import { RectLight } from '../components/Light';
9
- /**
10
- * 单关节机器人(SingleGripperRobot)
11
- * 基于 ModelAbs 重构,保留 Bot.js 核心运行行为:状态灯、沿 X 移动、手臂旋转、夹具切换。
12
- */
13
- export class SingleJointRobot extends ModelAbs {
14
- static DEFAULT_WIDTH = 90;
15
- static DEFAULT_HEIGHT = 76;
16
- static DEFAULT_LIGHT_COLOR = '#DFC285';
17
- light1 = null;
18
- light2 = null;
19
- defaultLightColor = SingleJointRobot.DEFAULT_LIGHT_COLOR;
20
- palletStationSlot = null;
21
- cutterStationSlot = null;
22
- createUi() {
23
- const { uuid, className, width = SingleJointRobot.DEFAULT_WIDTH, height = SingleJointRobot.DEFAULT_HEIGHT, x, y, zIndex, rotation, scale, visible, editable, draggable, currentFixture } = this.config;
24
- // 创建托盘工位槽
25
- this.palletStationSlot = new StationSlot({
26
- index: 10,
27
- x: 40,
28
- y: 25,
29
- width: 46,
30
- height: 46,
31
- hittable: this.config.hittable,
32
- showContainer: false,
33
- resourceType: EnumResourceType.PALLET,
34
- visible: currentFixture === EnumResourceType.PALLET ? true : 0
35
- }).init();
36
- // 创建刀具工位槽
37
- this.cutterStationSlot = new StationSlot({
38
- index: 10,
39
- x: 44,
40
- y: 25,
41
- width: 46,
42
- height: 46,
43
- hittable: this.config.hittable,
44
- showContainer: false,
45
- resourceType: EnumResourceType.TOOL,
46
- visible: currentFixture === EnumResourceType.TOOL ? true : 0
47
- }).init();
48
- // 小摆臂
49
- const smallArm = new Group({
50
- hitSelf: false,
51
- className: 'smallArm',
52
- x: 35,
53
- y: 30,
54
- zIndex: 1,
55
- around: {
56
- type: 'percent',
57
- x: 0.1,
58
- y: 0.5
59
- },
60
- children: [
61
- {
62
- hittable: false,
63
- tag: 'Box',
64
- width: 36,
65
- height: 16,
66
- stroke: 'rgba(0,0,0,0.1)',
67
- strokeWidth: 0.5,
68
- fill: {
69
- type: 'linear',
70
- stops: ['#FF6600', '#FFbb00', '#FF6600']
71
- },
72
- cornerRadius: [16, 0, 0, 16]
73
- },
74
- {
75
- hittable: false,
76
- className: 'smallArmJoint1',
77
- tag: 'Rect',
78
- width: 16,
79
- height: 16,
80
- fill: '#424242',
81
- cornerRadius: 16
82
- },
83
- {
84
- hittable: false,
85
- className: 'smallArmJoint2',
86
- tag: 'Rect',
87
- x: 36,
88
- width: 5,
89
- height: 16,
90
- fill: '#424242',
91
- cornerRadius: [0, 16, 16, 0]
92
- },
93
- // 夹具容器
94
- {
95
- hitSelf: false,
96
- className: 'fork',
97
- tag: 'Box',
98
- x: 30,
99
- y: -17,
100
- zIndex: -1,
101
- children: [
102
- {
103
- hitSelf: false,
104
- id: 'fixture',
105
- tag: 'Box',
106
- state: currentFixture,
107
- states: {
108
- // 托盘夹具
109
- [EnumResourceType.PALLET]: {
110
- hitSelf: false,
111
- width: 66,
112
- height: 50,
113
- cornerRadius: [15, 0, 0, 15],
114
- strokeWidth: 4,
115
- stroke: {
116
- type: 'linear',
117
- from: 'left',
118
- to: 'right',
119
- stops: [
120
- { offset: 0, color: '#424242' },
121
- { offset: 0.9, color: '#000' },
122
- { offset: 0.9, color: 'rgba(255, 0, 0, 0)' },
123
- { offset: 1, color: 'rgba(255, 0, 0, 0)' }
124
- ]
125
- },
126
- animation: {
127
- keyframes: [
128
- { opacity: 0, scaleX: 0 },
129
- { opacity: 1, scaleX: 1 }
130
- ],
131
- duration: 0.3
132
- }
133
- },
134
- // 刀具夹具
135
- [EnumResourceType.TOOL]: {
136
- tag: 'Box',
137
- width: 30,
138
- height: 12,
139
- y: 19,
140
- fill: {
141
- type: 'linear',
142
- from: 'left',
143
- to: 'right',
144
- stops: [
145
- { offset: 0, color: '#424242' },
146
- { offset: 0.75, color: '#666' },
147
- { offset: 0.75, color: '#424242' },
148
- { offset: 1, color: '#424242' }
149
- ]
150
- },
151
- children: [
152
- {
153
- className: 'cutterTip1',
154
- tag: 'Box',
155
- width: 6,
156
- height: 2,
157
- x: 24,
158
- y: 2,
159
- fill: '#000'
160
- },
161
- {
162
- className: 'cutterTip2',
163
- tag: 'Box',
164
- width: 6,
165
- height: 2,
166
- x: 24,
167
- y: 8,
168
- fill: '#000'
169
- }
170
- ]
171
- }
172
- }
173
- },
174
- this.palletStationSlot.ui,
175
- this.cutterStationSlot.ui
176
- ]
177
- }
178
- ]
179
- });
180
- // 大摆臂
181
- const bigArm = new Box({
182
- hittable: false,
183
- className: 'bigArm',
184
- width: 50,
185
- height: 30,
186
- x: 35,
187
- y: 30,
188
- cornerRadius: [15, 3, 3, 15],
189
- around: 'center',
190
- fill: {
191
- type: 'radial',
192
- stops: [
193
- { offset: 0, color: '#FFcc00' },
194
- { offset: 1, color: '#FF6600' }
195
- ]
196
- },
197
- shadow: {
198
- color: 'rgba(0,0,0,0.5)',
199
- spread: 0,
200
- blur: 2
201
- }
202
- });
203
- // 二级基座
204
- const secondBase = new Box({
205
- hitSelf: false,
206
- className: 'secondBase',
207
- width: 70,
208
- height: 60,
209
- x: 45,
210
- y: 38,
211
- cornerRadius: 10,
212
- around: 'center',
213
- fill: {
214
- type: 'radial',
215
- stops: [
216
- { offset: 0.3, color: '#FFcc00' },
217
- { offset: 1, color: '#FF6600' }
218
- ]
219
- },
220
- shadow: {
221
- color: 'rgba(0,0,0,0.5)',
222
- spread: 0,
223
- blur: 2
224
- },
225
- children: [
226
- ScrewHole({ x: 10, y: 10, styleType: 'dark' }),
227
- ScrewHole({ x: 62, y: 10, styleType: 'dark' }),
228
- ScrewHole({ x: 62, y: 50, styleType: 'dark' }),
229
- ScrewHole({ x: 10, y: 50, styleType: 'dark' }),
230
- {
231
- hitSelf: false,
232
- rotation: -rotation,
233
- tag: 'Box',
234
- width: 50,
235
- height: 50,
236
- around: 'center',
237
- x: width / 2 - 10,
238
- y: height / 2 - 8,
239
- fill: '#ee6600',
240
- cornerRadius: 50,
241
- strokeWidth: 1,
242
- stroke: 'rgba(255,255,255,0.65)',
243
- children: [
244
- createShadow({
245
- width: 50,
246
- height: 50,
247
- cornerRadius: 50,
248
- shadow: null,
249
- innerShadow: [
250
- {
251
- x: 4,
252
- y: 2,
253
- blur: 4,
254
- color: 'rgba(0,0,0,0.5)'
255
- },
256
- {
257
- x: -3,
258
- y: -1,
259
- blur: 3,
260
- color: 'rgba(255, 255, 255, 0.4)'
261
- }
262
- ]
263
- })
264
- ]
265
- }
266
- ]
267
- });
268
- secondBase.add([bigArm, smallArm]);
269
- // 主体
270
- const main = new Box({
271
- data: this.config,
272
- id: uuid,
273
- className,
274
- x,
275
- y,
276
- width,
277
- height,
278
- around: 'center',
279
- fill: '#FF9933',
280
- cornerRadius: 10,
281
- zIndex,
282
- rotation,
283
- scale,
284
- visible,
285
- editable,
286
- draggable,
287
- shadow: {
288
- spread: 1,
289
- blur: 4,
290
- color: 'rgba(0,0,0,0.5)'
291
- }
292
- });
293
- // 设备状态灯
294
- this.light1 = new RectLight({
295
- width: 30,
296
- height: 4,
297
- x: this.width_05,
298
- y: 4,
299
- color: this.defaultLightColor
300
- }).init();
301
- this.light2 = new RectLight({
302
- width: 30,
303
- height: 4,
304
- x: this.width_05,
305
- y: height - 4,
306
- color: this.defaultLightColor
307
- }).init();
308
- main.add([this.light1.ui, this.light2.ui, secondBase]);
309
- setCursor(main, this.config);
310
- return main;
311
- }
312
- operating(data) {
313
- if (data.light && this.light1 && this.light2) {
314
- this.light1.operating(data.light);
315
- this.light2.operating(data.light);
316
- }
317
- if (typeof data.x === 'number')
318
- this.moveX(data.x);
319
- if (typeof data.r === 'number')
320
- this.handleRotate(data.r);
321
- if (data.currentFixture)
322
- this.switchFork(data.currentFixture);
323
- }
324
- handleRotate(r) {
325
- if (!Number.isFinite(r))
326
- return;
327
- this.ui.findOne('.bigArm')?.animate({ rotation: -r, duration: 0.5 });
328
- this.ui.findOne('.smallArm')?.animate({ rotation: r, duration: 0.5 });
329
- this.ui.findOne('.secondBase')?.animate({ offsetX: Math.abs(r / 9) - 10, duration: 0.5 });
330
- }
331
- moveX(x) {
332
- if (!Number.isFinite(x))
333
- return;
334
- this.ui.animate({ x, duration: 0.25 });
335
- }
336
- // 切换夹具类型
337
- switchFork(type) {
338
- if (this.palletStationSlot) {
339
- this.palletStationSlot.toggleVisible(type === EnumResourceType.PALLET ? true : 0);
340
- }
341
- if (this.cutterStationSlot) {
342
- this.cutterStationSlot.toggleVisible(type === EnumResourceType.TOOL ? true : 0);
343
- }
344
- this.ui.findOne('#fixture')?.set({ state: type });
345
- }
346
- }
@@ -1,85 +0,0 @@
1
- /**
2
- * @Author : TanRui
3
- * @WeChat : Tan578853789
4
- * @File : NamePlate.ts
5
- * @Date : 2026/02/12
6
- * @Desc. : 铭牌
7
- */
8
- import { Box, Text } from 'leafer';
9
- import { ScrewHole } from './ScrewHole';
10
- export function NamePlate(options) {
11
- const opts = {
12
- x: 0,
13
- y: 0,
14
- width: undefined, // 显式区分是否传入
15
- height: 18,
16
- cornerRadius: 2,
17
- fill: '#f2f2f2',
18
- textColor: '#d15f2c',
19
- fontSize: 14,
20
- stroke: 'rgba(0,0,0,0.2)',
21
- strokeWidth: 1,
22
- screwHole: true,
23
- zIndex: '',
24
- ...options
25
- };
26
- // 默认宽度:按字符估算
27
- const defaultWidth = Math.max(20, (opts.title.length + 2) * opts.fontSize);
28
- const finalWidth = opts.width ?? defaultWidth;
29
- // 文本节点配置
30
- const textConfig = {
31
- text: opts.title,
32
- textAlign: 'center',
33
- verticalAlign: 'middle',
34
- fill: opts.textColor,
35
- fontWeight: 'black',
36
- width: finalWidth,
37
- height: opts.height,
38
- lineHeight: opts.height, // 行距为 0
39
- wordWrap: !!opts.width, // 仅当指定了 width 时才允许换行
40
- overflow: 'hide'
41
- };
42
- // 如果指定了 width,则使用较小字号尝试适配
43
- if (opts.width !== undefined) {
44
- textConfig.fontSize = Math.min(opts.fontSize, 12);
45
- }
46
- else {
47
- textConfig.fontSize = opts.fontSize;
48
- }
49
- const textNode = new Text(textConfig);
50
- const box = new Box({
51
- hittable: false,
52
- className: 'name-plate',
53
- x: opts.x,
54
- y: opts.y,
55
- width: finalWidth,
56
- height: opts.height,
57
- fill: opts.fill,
58
- overflow: 'hide',
59
- around: 'center',
60
- stroke: opts.stroke,
61
- strokeWidth: opts.strokeWidth,
62
- cornerRadius: opts.cornerRadius,
63
- zIndex: opts.zIndex,
64
- children: [textNode]
65
- });
66
- // 添加螺丝孔
67
- if (opts.screwHole) {
68
- const height_05 = opts.height / 2;
69
- const holeSize = 4;
70
- const leftScrew = ScrewHole({
71
- x: holeSize,
72
- y: height_05,
73
- width: holeSize,
74
- height: holeSize
75
- });
76
- const rightScrew = ScrewHole({
77
- x: finalWidth - holeSize,
78
- y: height_05,
79
- width: holeSize,
80
- height: holeSize
81
- });
82
- box.add([leftScrew, rightScrew]);
83
- }
84
- return box;
85
- }
@@ -1,57 +0,0 @@
1
- /**
2
- * @Author : TanRui
3
- * @WeChat : Tan578853789
4
- * @File : ScrewHole.ts
5
- * @Date : 2026/02/12
6
- * @Desc. : 梅花螺丝孔
7
- */
8
- import { Box, Star } from 'leafer';
9
- export function ScrewHole(options = {}) {
10
- const opts = {
11
- x: 0,
12
- y: 0,
13
- width: 5,
14
- height: 5,
15
- fill: '',
16
- styleType: 'light',
17
- ...options
18
- };
19
- // 根据 styleType 自动设置 fill
20
- if (options.fill === undefined) {
21
- opts.fill = opts.styleType === 'dark' ? '#777' : '#ccc';
22
- }
23
- const strokeWidth = 0.15;
24
- const strokeColor = opts.styleType === 'dark' ? '#333' : '#888';
25
- const screwHole = new Box({
26
- hittable: false,
27
- className: 'screw-hole',
28
- x: opts.x,
29
- y: opts.y,
30
- width: opts.width,
31
- height: opts.height,
32
- fill: opts.fill,
33
- cornerRadius: opts.width / 2,
34
- stroke: strokeColor,
35
- strokeWidth: strokeWidth,
36
- around: 'center'
37
- });
38
- // 如果需要中心标记
39
- const markSize = Math.min(opts.width, opts.height);
40
- const width_05 = opts.width / 2;
41
- const height_05 = opts.height / 2;
42
- // 梅花图案
43
- const torx = new Star({
44
- x: width_05,
45
- y: height_05,
46
- width: markSize,
47
- height: markSize,
48
- innerRadius: 0.25,
49
- corners: 5,
50
- cornerRadius: 2,
51
- rotation: 30,
52
- fill: strokeColor,
53
- around: 'center'
54
- });
55
- screwHole.add(torx);
56
- return screwHole;
57
- }
@@ -1,51 +0,0 @@
1
- /**
2
- * @Author : TanRui
3
- * @WeChat : Tan578853789
4
- * @File : Texture.ts
5
- * @Date : 2025/05/30
6
- * @Desc. : 纹理
7
- */
8
- import { Box, Rect } from 'leafer';
9
- import LightGrid from '@/assets/images/texture/LightGrid.png';
10
- import DarkGrid from '@/assets/images/texture/DarkGrid.png';
11
- import MatrixGrid from '@/assets/images/texture/MatrixGrid.png';
12
- import LightDot from '@/assets/images/texture/LightDot.png';
13
- import DarkDot from '@/assets/images/texture/DarkDot.png';
14
- import WoodFloor from '@/assets/images/texture/WoodFloor.png';
15
- import VerticalBar from '@/assets/images/texture/VerticalBar.png';
16
- const EFFECT_MAP = {
17
- LightGrid,
18
- DarkGrid,
19
- MatrixGrid,
20
- LightDot,
21
- DarkDot,
22
- WoodFloor,
23
- VerticalBar
24
- };
25
- export function Texture(options = {}) {
26
- const { className = 'Texture', width = 0, height = 0, effect = 'LightGrid', opacity = 1, scale = 0.02, rotation = 0, cornerRadius = 0, fill } = options;
27
- return new Box({
28
- hittable: false,
29
- className,
30
- width,
31
- height,
32
- fill,
33
- cornerRadius,
34
- overflow: 'hide',
35
- children: [
36
- new Rect({
37
- className: 'Texture-Image',
38
- width,
39
- height,
40
- opacity,
41
- fill: {
42
- type: 'image',
43
- url: EFFECT_MAP[effect],
44
- mode: 'repeat',
45
- scale,
46
- rotation
47
- }
48
- })
49
- ]
50
- });
51
- }
@@ -1,50 +0,0 @@
1
- /**
2
- * @Author : TanRui
3
- * @WeChat : Tan578853789
4
- * @File : attr.ts
5
- * @Date : 2026/04/07
6
- * @Desc. : 修改属性的工具函数
7
- */
8
- import {} from 'leafer';
9
- /**
10
- * 根据交互属性设置鼠标样式和 hover 效果
11
- * @param target UI 目标对象
12
- * @param data 交互属性数据
13
- * @param type 效果类型,默认为 'shadow',可选 'border'('border' 特别适用于 overflow: 'hidden' 的容器)
14
- */
15
- export function setCursor(target, data, type = 'shadow') {
16
- if (data.hittable && data.hitSelf && (data.clickable || data.menuClickable || data.draggable)) {
17
- let cursor = 'default';
18
- const color = '#806EF7';
19
- if (data.clickable) {
20
- cursor = 'pointer';
21
- }
22
- else if (data.menuClickable) {
23
- cursor = 'context-menu';
24
- }
25
- else if (data.draggable) {
26
- cursor = 'move';
27
- }
28
- if (type === 'shadow') {
29
- target.set({
30
- cursor,
31
- hoverStyle: {
32
- shadow: {
33
- spread: 2,
34
- blur: 2,
35
- color
36
- }
37
- }
38
- });
39
- }
40
- else if (type === 'border') {
41
- target.set({
42
- cursor,
43
- hoverStyle: {
44
- stroke: color,
45
- strokeWidth: 3
46
- }
47
- });
48
- }
49
- }
50
- }
@@ -1,92 +0,0 @@
1
- /**
2
- * @Author : TanRui
3
- * @WeChat : Tan578853789
4
- * @File : index.ts
5
- * @Date : 2025/04/29
6
- * @Desc. : 工具类
7
- */
8
- /**
9
- * 数字生成器
10
- * @param {*} start 起始值
11
- * @param {*} end 结束值
12
- * @param {*} shouldLoop 是否无限循环
13
- * @returns
14
- */
15
- export function* numberLoopGenerator(start, end, shouldLoop = false) {
16
- let current = start;
17
- while (true) {
18
- // 使用无限循环
19
- if (current > end) {
20
- if (!shouldLoop) {
21
- return;
22
- }
23
- else {
24
- current = start;
25
- }
26
- }
27
- yield current++;
28
- }
29
- }
30
- /**
31
- * 在 n 秒内把变量从值 x 线性递增到 y
32
- * @param {*} x 初始值
33
- * @param {*} y 结束值
34
- * @param {*} n 递增时长
35
- * @param {*} rate 帧率(别低于100否则进度条动画来不及显示)
36
- * @param {*} callback 回调函数
37
- * @returns
38
- */
39
- export const linearIncrease = (x = 0, y = 100, n = 3, rate = 300, callback) => {
40
- if (!callback) {
41
- return false;
42
- }
43
- return new Promise((resolve) => {
44
- // if (x >= y) {
45
- // resolve()
46
- // return
47
- // }
48
- const start = x;
49
- const target = y;
50
- let elapsed = 0;
51
- const duration = n * 1000;
52
- const interval = setInterval(() => {
53
- elapsed += rate;
54
- // 计算进度 [0 ~ 1]
55
- const progress = Math.min(elapsed / duration, 1);
56
- // 线性插值
57
- const currentValue = start + (target - start) * progress;
58
- callback(currentValue.toFixed(2));
59
- // 如果动画完成
60
- if (progress === 1) {
61
- clearInterval(interval);
62
- resolve;
63
- }
64
- }, rate);
65
- });
66
- };
67
- /**
68
- * 根据百分比数字转换为像素,或者根据像素转换为百分比
69
- * @param {number} val - 百分比数字(范围 0 ~ 1),或者像素数字
70
- * @param {number} size - 尺寸,用于计算百分比
71
- * @param {number} [precision=3] - 保留的小数位数,默认为 3
72
- * @param {boolean} [getPercent=false] - 是否返回百分比,默认为 false
73
- * @returns {number} 转换后的像素值
74
- */
75
- export function transPercentAndPixel(val, size, precision = 3, getPercent) {
76
- if (val === undefined || size === undefined) {
77
- return 0;
78
- }
79
- if (getPercent) {
80
- return size > 0 ? Number((val / size).toFixed(3)) : 0;
81
- }
82
- return Number((size * val).toFixed(precision));
83
- }
84
- // 百分比转换小数
85
- export function transFraction(val, size) {
86
- if (val === undefined || size === undefined)
87
- return 0;
88
- if (size > 0) {
89
- return Number((val / size).toFixed(3));
90
- }
91
- return val;
92
- }