@jnrs/lingshu-smart 2.2.6 → 2.2.8

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 (174) hide show
  1. package/dist/App.vue.d.ts +2 -1
  2. package/dist/App.vue.js +30 -0
  3. package/dist/assets/data/editor_default.d.ts +8 -1
  4. package/dist/assets/data/editor_default.js +59 -0
  5. package/dist/assets/data/editor_default_setting.d.ts +16 -0
  6. package/dist/assets/data/editor_default_setting.js +58 -0
  7. package/dist/assets/data/editor_preset.d.ts +8 -1
  8. package/dist/assets/data/editor_preset.js +51 -0
  9. package/dist/assets/data/editor_preset_menu.d.ts +9 -0
  10. package/dist/assets/data/editor_preset_menu.js +290 -0
  11. package/dist/components/editor/ControlBar/CaseManger.vue.d.ts +3 -15
  12. package/dist/components/editor/ControlBar/CaseManger.vue.js +465 -0
  13. package/dist/components/editor/ControlBar/CaseTitleEdit.vue.d.ts +2 -411
  14. package/dist/components/editor/ControlBar/CaseTitleEdit.vue.js +108 -0
  15. package/dist/components/editor/ControlBar/ExportImportDialog.vue.d.ts +3 -2
  16. package/dist/components/editor/ControlBar/ExportImportDialog.vue.js +280 -0
  17. package/dist/components/editor/ControlBar/MainButton.vue.d.ts +3 -2
  18. package/dist/components/editor/ControlBar/MainButton.vue.js +183 -0
  19. package/dist/components/editor/ControlBar/StepButton.vue.d.ts +2 -1
  20. package/dist/components/editor/ControlBar/StepButton.vue.js +147 -0
  21. package/dist/components/editor/ControlBar/StepRecordVisualizer.vue.d.ts +2 -1
  22. package/dist/components/editor/ControlBar/StepRecordVisualizer.vue.js +98 -0
  23. package/dist/components/editor/DrawingBoard.vue.d.ts +2 -1
  24. package/dist/components/editor/DrawingBoard.vue.js +31 -0
  25. package/dist/components/editor/MenuCard/Equipments.vue.d.ts +2 -1
  26. package/dist/components/editor/MenuCard/Equipments.vue.js +129 -0
  27. package/dist/components/editor/MenuCard/Layers.vue.d.ts +2 -1
  28. package/dist/components/editor/MenuCard/Layers.vue.js +201 -0
  29. package/dist/components/editor/MenuCard/index.vue.d.ts +2 -1
  30. package/dist/components/editor/MenuCard/index.vue.js +84 -0
  31. package/dist/components/editor/OptionCard/Equipment/Base.vue.d.ts +2 -1
  32. package/dist/components/editor/OptionCard/Equipment/Base.vue.js +96 -0
  33. package/dist/components/editor/OptionCard/Equipment/Binds.vue.d.ts +3 -0
  34. package/dist/components/editor/OptionCard/Equipment/Binds.vue.js +443 -0
  35. package/dist/components/editor/OptionCard/Equipment/Bot.vue.d.ts +3 -0
  36. package/dist/components/editor/OptionCard/Equipment/Bot.vue.js +81 -0
  37. package/dist/components/editor/OptionCard/Equipment/DataSets.vue.d.ts +2 -1
  38. package/dist/components/editor/OptionCard/Equipment/DataSets.vue.js +304 -0
  39. package/dist/components/editor/OptionCard/Equipment/DockStore.vue.d.ts +3 -0
  40. package/dist/components/editor/OptionCard/Equipment/DockStore.vue.js +597 -0
  41. package/dist/components/editor/OptionCard/Equipment/Interaction.vue.d.ts +2 -1
  42. package/dist/components/editor/OptionCard/Equipment/Interaction.vue.js +287 -0
  43. package/dist/components/editor/OptionCard/Equipment/Position.backup.vue.d.ts +3 -0
  44. package/dist/components/editor/OptionCard/Equipment/Position.backup.vue.js +440 -0
  45. package/dist/components/editor/OptionCard/Equipment/Position.vue.d.ts +2 -1
  46. package/dist/components/editor/OptionCard/Equipment/Position.vue.js +436 -0
  47. package/dist/components/editor/OptionCard/Equipment/StationSlotGroup.vue.d.ts +2 -1
  48. package/dist/components/editor/OptionCard/Equipment/StationSlotGroup.vue.js +1131 -0
  49. package/dist/components/editor/OptionCard/Equipment/Store.vue.d.ts +3 -0
  50. package/dist/components/editor/OptionCard/Equipment/Store.vue.js +453 -0
  51. package/dist/components/editor/OptionCard/Equipment/Trailer.vue.d.ts +3 -0
  52. package/dist/components/editor/OptionCard/Equipment/Trailer.vue.js +1109 -0
  53. package/dist/components/editor/OptionCard/Equipment/index.vue.d.ts +2 -1
  54. package/dist/components/editor/OptionCard/Equipment/index.vue.js +100 -0
  55. package/dist/components/editor/OptionCard/Equipment/models/MachineTool.vue.d.ts +3 -0
  56. package/dist/components/editor/OptionCard/Equipment/models/MachineTool.vue.js +99 -0
  57. package/dist/components/editor/OptionCard/Equipment/models/Rail.vue.d.ts +3 -0
  58. package/dist/components/editor/OptionCard/Equipment/models/Rail.vue.js +225 -0
  59. package/dist/components/editor/OptionCard/Equipment/models/SingleGripperRobot.vue.d.ts +3 -0
  60. package/dist/components/editor/OptionCard/Equipment/models/SingleGripperRobot.vue.js +99 -0
  61. package/dist/components/editor/OptionCard/Scene/Background.vue.d.ts +2 -1
  62. package/dist/components/editor/OptionCard/Scene/Background.vue.js +543 -0
  63. package/dist/components/editor/OptionCard/Scene/index.vue.d.ts +2 -1
  64. package/dist/components/editor/OptionCard/Scene/index.vue.js +200 -0
  65. package/dist/components/editor/OptionCard/index.vue.d.ts +2 -1
  66. package/dist/components/editor/OptionCard/index.vue.js +73 -0
  67. package/dist/components/editor/index.vue.d.ts +4 -13
  68. package/dist/components/editor/index.vue.js +156 -0
  69. package/dist/components/index.d.ts +2 -2
  70. package/dist/components/index.js +4 -25440
  71. package/dist/components/preview/index.vue.d.ts +6 -5
  72. package/dist/components/preview/index.vue.js +104 -0
  73. package/dist/composables/useStepRecord.d.ts +12 -4
  74. package/dist/composables/useStepRecord.js +135 -0
  75. package/dist/constants/options.d.ts +8 -1
  76. package/dist/constants/options.js +55 -0
  77. package/dist/controller/AppController.d.ts +10 -3
  78. package/dist/controller/AppController.js +168 -0
  79. package/dist/controller/EditorController.d.ts +9 -2
  80. package/dist/controller/EditorController.js +173 -0
  81. package/dist/index.js +1 -1
  82. package/dist/locales/en.js +5 -0
  83. package/dist/locales/i18next.d.ts +1 -1
  84. package/dist/locales/i18next.js +6 -0
  85. package/dist/locales/index.d.ts +2 -2
  86. package/dist/locales/index.js +3 -13
  87. package/dist/locales/zhCn.js +5 -0
  88. package/dist/main.d.ts +3 -0
  89. package/dist/main.js +13 -0
  90. package/dist/playground/EditPageDemo.vue.d.ts +2 -1
  91. package/dist/playground/EditPageDemo.vue.js +57 -0
  92. package/dist/playground/ViewPageDemo.vue.d.ts +2 -27
  93. package/dist/playground/ViewPageDemo.vue.js +277 -0
  94. package/dist/stores/index.js +3 -0
  95. package/dist/stores/useAppStore.d.ts +13 -6
  96. package/dist/stores/useAppStore.js +78 -0
  97. package/dist/stores/useDataStore.d.ts +18 -11
  98. package/dist/stores/useDataStore.js +116 -0
  99. package/dist/stores/useEditorStore.d.ts +27 -20
  100. package/dist/stores/useEditorStore.js +263 -0
  101. package/dist/types/app.types.d.ts +1 -1
  102. package/dist/types/app.types.js +2 -0
  103. package/dist/types/base.types.d.ts +4 -2
  104. package/dist/types/base.types.js +1 -0
  105. package/dist/types/components/config.types.d.ts +11 -3
  106. package/dist/types/components/config.types.js +1 -0
  107. package/dist/types/components/operating.types.d.ts +1 -1
  108. package/dist/types/components/operating.types.js +1 -0
  109. package/dist/types/enums.d.ts +5 -2
  110. package/dist/types/enums.js +46 -0
  111. package/dist/types/guards.d.ts +12 -2
  112. package/dist/types/guards.js +28 -0
  113. package/dist/types/index.d.ts +2 -2
  114. package/dist/types/index.js +8 -0
  115. package/dist/types/models/config.types.d.ts +74 -29
  116. package/dist/types/models/config.types.js +1 -0
  117. package/dist/types/models/operating.types.d.ts +83 -17
  118. package/dist/types/models/operating.types.js +1 -0
  119. package/dist/ui/abstract/ComponentAbs.d.ts +9 -2
  120. package/dist/ui/abstract/ComponentAbs.js +64 -0
  121. package/dist/ui/abstract/ModelAbs.d.ts +12 -2
  122. package/dist/ui/abstract/ModelAbs.js +119 -0
  123. package/dist/ui/components/Entrance.d.ts +8 -1
  124. package/dist/ui/components/Entrance.js +83 -0
  125. package/dist/ui/components/Light.d.ts +26 -3
  126. package/dist/ui/components/Light.js +167 -0
  127. package/dist/ui/components/Progress.d.ts +8 -1
  128. package/dist/ui/components/Progress.js +84 -0
  129. package/dist/ui/components/Resource.d.ts +8 -1
  130. package/dist/ui/components/Resource.js +70 -0
  131. package/dist/ui/components/StationSlot.d.ts +24 -2
  132. package/dist/ui/components/StationSlot.js +207 -0
  133. package/dist/ui/components/StationSlotGroup.d.ts +8 -1
  134. package/dist/ui/components/StationSlotGroup.js +110 -0
  135. package/dist/ui/factories/createGlass.d.ts +9 -1
  136. package/dist/ui/factories/createGlass.js +51 -0
  137. package/dist/ui/factories/createModel.d.ts +9 -2
  138. package/dist/ui/factories/createModel.js +35 -0
  139. package/dist/ui/factories/createShadow.d.ts +12 -4
  140. package/dist/ui/factories/createShadow.js +52 -0
  141. package/dist/ui/factories/createText.d.ts +7 -0
  142. package/dist/ui/factories/createText.js +46 -0
  143. package/dist/ui/models/CleaningMachine.d.ts +14 -0
  144. package/dist/ui/models/CleaningMachine.js +141 -0
  145. package/dist/ui/models/DoubleJointRobot.d.ts +23 -0
  146. package/dist/ui/models/DoubleJointRobot.js +545 -0
  147. package/dist/ui/models/LoadingStation.d.ts +16 -0
  148. package/dist/ui/models/LoadingStation.js +167 -0
  149. package/dist/ui/models/MachineTool.d.ts +5 -4
  150. package/dist/ui/models/MachineTool.js +184 -0
  151. package/dist/ui/models/MarkingMachine.d.ts +16 -0
  152. package/dist/ui/models/MarkingMachine.js +148 -0
  153. package/dist/ui/models/Rail.d.ts +15 -0
  154. package/dist/ui/models/Rail.js +117 -0
  155. package/dist/ui/models/ResourceStore.d.ts +12 -0
  156. package/dist/ui/models/ResourceStore.js +101 -0
  157. package/dist/ui/models/SingleBot.d.ts +20 -0
  158. package/dist/ui/models/SingleBot.js +202 -0
  159. package/dist/ui/models/SingleGripperRobot.d.ts +19 -0
  160. package/dist/ui/models/SingleGripperRobot.js +272 -0
  161. package/dist/ui/models/SingleJointRobot.d.ts +22 -0
  162. package/dist/ui/models/SingleJointRobot.js +346 -0
  163. package/dist/ui/shapes/NamePlate.d.ts +10 -1
  164. package/dist/ui/shapes/NamePlate.js +85 -0
  165. package/dist/ui/shapes/ScrewHole.d.ts +8 -1
  166. package/dist/ui/shapes/ScrewHole.js +57 -0
  167. package/dist/ui/shapes/Texture.d.ts +12 -3
  168. package/dist/ui/shapes/Texture.js +51 -0
  169. package/dist/ui/utils/attr.d.ts +10 -3
  170. package/dist/ui/utils/attr.js +50 -0
  171. package/dist/utils/index.js +92 -0
  172. package/dist/utils/type-guards.d.ts +1 -1
  173. package/dist/utils/type-guards.js +105 -0
  174. package/package.json +2 -2
@@ -0,0 +1,207 @@
1
+ /**
2
+ * @Author : TanRui
3
+ * @WeChat : Tan578853789
4
+ * @File : StationSlot.ts
5
+ * @Date : 2026/02/12
6
+ *
7
+ * @classdesc
8
+ * 工位槽位(Station Slot)是工位中用于承载资源(Resource)的容器。
9
+ * 它负责管理资源的生命周期,包括添加、移除及状态同步,确保资源与工位之间的强关联和统一控制。
10
+ *
11
+ * @design
12
+ * 当前采用 **方案一:真实添加/移除资源对象**。
13
+ * - 资源在插入时被实际加入场景图(或容器),移除时从场景中销毁或解绑。
14
+ * - 优点:逻辑直观,内存管理明确。
15
+ * - 缺点:频繁创建/销毁可能影响性能(尤其在高频率操作场景)。
16
+ *
17
+ * @future
18
+ * 后续可根据实际性能表现,切换至 **方案二:通过可见性(如 `visible` 属性)模拟添加/移除**。
19
+ * - 资源始终存在于场景中,仅通过状态控制显示/隐藏。
20
+ * - 适用于需要频繁切换但资源复用率高的场景。
21
+ * - 基于方案一、二再添加个对象池机制的混合模式,即优先去资源池读取。
22
+ */
23
+ import { EnumResourceType, EnumComponent } from '@/types';
24
+ import { Box, Text } from 'leafer';
25
+ import { Resource } from './Resource';
26
+ import { createShadow } from '../factories/createShadow';
27
+ import { createText } from '../factories/createText';
28
+ import { ComponentAbs } from '../abstract/ComponentAbs';
29
+ import { setCursor } from '../utils/attr';
30
+ export class StationSlot extends ComponentAbs {
31
+ children = [];
32
+ constructor(options) {
33
+ const DEFAULTS = {
34
+ className: EnumComponent.STATION_SLOT,
35
+ name: '',
36
+ index: 0,
37
+ x: 0,
38
+ y: 0,
39
+ width: 50,
40
+ height: 50,
41
+ rotation: 0,
42
+ parentRotation: 0,
43
+ resourceType: EnumResourceType.PALLET,
44
+ disabled: false,
45
+ hittable: true,
46
+ visible: true,
47
+ showContainer: true
48
+ };
49
+ super({ ...DEFAULTS, ...options });
50
+ }
51
+ // 创建 UI
52
+ createUi() {
53
+ const { x, y, name, width, height, resourceType, hittable, disabled, visible, showContainer, origin = 'center', around = 'center' } = this.config;
54
+ const main = new Box({
55
+ hittable,
56
+ visible,
57
+ className: `StationSlot-${resourceType}`,
58
+ x,
59
+ y,
60
+ width,
61
+ height,
62
+ origin,
63
+ around,
64
+ disabled,
65
+ cornerRadius: this.autoCornerRadius,
66
+ rotation: this.autoFixRotation,
67
+ fill: 'rgba(255, 255, 255, 0.3)',
68
+ hitFill: 'all',
69
+ stroke: 'rgba(255, 255, 255, 0.7)',
70
+ strokeWidth: 3,
71
+ data: this.config,
72
+ children: [
73
+ createText({
74
+ name,
75
+ width,
76
+ height,
77
+ fill: 'rgba(0,0,0,0.2)'
78
+ })
79
+ ]
80
+ });
81
+ // 可交互时添加 hover 状态
82
+ setCursor(main, { hittable: this.config.hittable, hitSelf: true, clickable: true }, 'border');
83
+ if (showContainer) {
84
+ const shadowCvs = createShadow({
85
+ width,
86
+ height,
87
+ cornerRadius: this.autoCornerRadius,
88
+ shadow: null
89
+ });
90
+ main.add(shadowCvs);
91
+ }
92
+ else {
93
+ main.fill = 'rgba(0, 0, 0, 0)';
94
+ main.stroke = 'rgba(0, 0, 0, 0)';
95
+ }
96
+ return main;
97
+ }
98
+ // 自动计算工位槽位的旋转补偿角度
99
+ get autoFixRotation() {
100
+ const parentRotation = this.config.parentRotation;
101
+ const rotation = this.config.rotation ?? 0;
102
+ if (!parentRotation)
103
+ return rotation;
104
+ let r = 0;
105
+ if (parentRotation === 90)
106
+ r = -90;
107
+ if (parentRotation === -90)
108
+ r = 90;
109
+ if (parentRotation > 90)
110
+ r = -180;
111
+ if (parentRotation < -90)
112
+ r = 180;
113
+ return r + rotation;
114
+ }
115
+ // 根据类型自动计算圆角
116
+ get autoCornerRadius() {
117
+ const defaultType = this.config.resourceType;
118
+ const width = this.config.width || 0;
119
+ return defaultType === EnumResourceType.TOOL ? width : width * 0.1;
120
+ }
121
+ // private setupClickableArea(cornerRadius: number): void {
122
+ // const clickableBox = new Box({
123
+ // className: 'palletAndCutterSiteClickableBox',
124
+ // width: this.config.width,
125
+ // height: this.config.height,
126
+ // fill: '#f40',
127
+ // opacity: 0,
128
+ // cornerRadius,
129
+ // hoverStyle: {
130
+ // opacity: 1,
131
+ // zIndex: 0
132
+ // },
133
+ // children: [
134
+ // new Text({
135
+ // text: '放置',
136
+ // textAlign: 'center',
137
+ // verticalAlign: 'middle',
138
+ // lineHeight: this.config.width * 0.4,
139
+ // fontSize: this.config.width * 0.4,
140
+ // fontWeight: 'black',
141
+ // fill: '#fff',
142
+ // width: this.config.width,
143
+ // height: this.config.height
144
+ // })
145
+ // ]
146
+ // })
147
+ // this.ui?.add(clickableBox)
148
+ // }
149
+ /**
150
+ * 添加托盘
151
+ * @param d
152
+ */
153
+ addPallet(d) {
154
+ const { width, height, resourceType } = this.config;
155
+ const resource = new Resource({
156
+ x: this.width_05,
157
+ y: this.height_05,
158
+ width: width - 5,
159
+ height: height - 5,
160
+ name: d.name,
161
+ color: d.color,
162
+ resourceType,
163
+ rawData: d.rawData
164
+ }).init();
165
+ this.children.push(resource);
166
+ this.ui.add(resource.ui);
167
+ }
168
+ /**
169
+ * 移除托盘
170
+ * @param d
171
+ */
172
+ removeAllPallet(d) {
173
+ for (const item of this.children) {
174
+ item.ui.destroy();
175
+ }
176
+ this.children = [];
177
+ }
178
+ /**
179
+ * 设置工位是否正在使用
180
+ * @param flag
181
+ */
182
+ setSiteWorking(flag) {
183
+ const anim = flag
184
+ ? {
185
+ animation: {
186
+ style: { fill: 'rgb(0, 255, 42)' },
187
+ duration: 0.5,
188
+ reverse: true,
189
+ swing: true,
190
+ loop: true
191
+ }
192
+ }
193
+ : { animation: { style: { fill: '' } } };
194
+ this.ui?.set(anim);
195
+ }
196
+ // 切换 ui 的 visible
197
+ toggleVisible(visible) {
198
+ this.ui?.set({ visible });
199
+ }
200
+ /**
201
+ * 销毁
202
+ */
203
+ destroyUI() {
204
+ this.removeAllPallet();
205
+ this.ui?.destroy();
206
+ }
207
+ }
@@ -1,5 +1,12 @@
1
+ /**
2
+ * @Author : TanRui
3
+ * @WeChat : Tan578853789
4
+ * @File : StationSlotGroup.ts
5
+ * @Date : 2026/04/08
6
+ * @Desc. : 工位槽位组容器(类封装,支持动态操作)
7
+ */
1
8
  import { Flow } from 'leafer';
2
- import { IResourceOperating, IStationSlotGroupConfig } from '../../types';
9
+ import type { IResourceOperating, IStationSlotGroupConfig } from '@/types';
3
10
  import { ComponentAbs } from '../abstract/ComponentAbs';
4
11
  /**
5
12
  * 工位槽位组容器
@@ -0,0 +1,110 @@
1
+ /**
2
+ * @Author : TanRui
3
+ * @WeChat : Tan578853789
4
+ * @File : StationSlotGroup.ts
5
+ * @Date : 2026/04/08
6
+ * @Desc. : 工位槽位组容器(类封装,支持动态操作)
7
+ */
8
+ import { UI, Flow } from 'leafer';
9
+ import { StationSlot } from '../components/StationSlot';
10
+ import { ComponentAbs } from '../abstract/ComponentAbs';
11
+ /**
12
+ * 工位槽位组容器
13
+ * @param config - 工位槽位组配置
14
+ * @param rotation - 可选的旋转角度,应用于所有子槽位
15
+ * @returns StationSlotGroup 实例,包含 Flow 容器和操作方法
16
+ */
17
+ export class StationSlotGroup extends ComponentAbs {
18
+ parentRotation;
19
+ stationSlotInstances; // 存储 StationSlot 实例的 Map,key 为 IStationSlotConfig.index
20
+ constructor(options, parentRotation) {
21
+ super(options);
22
+ this.parentRotation = parentRotation || 0;
23
+ this.stationSlotInstances = new Map();
24
+ }
25
+ // 获取自动宽度来限制工位换行
26
+ get autoSize() {
27
+ const { flowOptions, stationSlots } = this.config;
28
+ const flow = flowOptions.flow;
29
+ const flowWrap = flowOptions.flowWrap;
30
+ const quantity = flowOptions.oneDirectionMaxQuantity;
31
+ const gapOffset = flowOptions.gap * (quantity - 1);
32
+ const maxWidth = Math.max(...stationSlots.map((d) => d.width));
33
+ const maxHeight = Math.max(...stationSlots.map((d) => d.height));
34
+ if (flowWrap === false) {
35
+ return {
36
+ width: this.config.width,
37
+ height: this.config.height
38
+ };
39
+ }
40
+ if (flow === 'x' || flow === 'x-reverse') {
41
+ return {
42
+ width: maxWidth * quantity + gapOffset,
43
+ height: this.config.height
44
+ };
45
+ }
46
+ if (flow === 'y' || flow === 'y-reverse') {
47
+ return {
48
+ width: this.config.width,
49
+ height: maxHeight * quantity + gapOffset
50
+ };
51
+ }
52
+ return {
53
+ width: this.config.width,
54
+ height: this.config.height
55
+ };
56
+ }
57
+ // 创建 UI
58
+ createUi() {
59
+ const { x, y, rotation, zIndex, stationSlots, flowOptions, hittable = true, origin = 'center', around = 'center' } = this.config;
60
+ const stationSlotsUi = [];
61
+ for (const item of stationSlots) {
62
+ if (typeof item.index !== 'number') {
63
+ console.warn('StationSlot 缺少有效的 index 字段:', item);
64
+ continue;
65
+ }
66
+ const slotInstance = new StationSlot({
67
+ ...item,
68
+ parentRotation: this.parentRotation
69
+ }).init();
70
+ this.stationSlotInstances.set(item.index, slotInstance);
71
+ stationSlotsUi.push(slotInstance.ui);
72
+ }
73
+ const main = new Flow({
74
+ ...flowOptions,
75
+ className: 'StationSlotGroup',
76
+ hittable,
77
+ x,
78
+ y,
79
+ rotation,
80
+ zIndex,
81
+ width: this.autoSize.width,
82
+ height: this.autoSize.height,
83
+ origin,
84
+ around,
85
+ flowAlign: 'center',
86
+ children: stationSlotsUi
87
+ });
88
+ return main;
89
+ }
90
+ /**
91
+ * 操作方法:处理资源新增/移除
92
+ */
93
+ operating(val) {
94
+ if (typeof val.index !== 'number') {
95
+ console.warn('IResourceOperating 缺少有效的 index 字段:', val);
96
+ return;
97
+ }
98
+ const stationSlot = this.stationSlotInstances.get(val.index);
99
+ if (!stationSlot) {
100
+ console.warn(`处理资源失败:未找到 index=${val.index} 的工位槽,rawData:`, val.rawData);
101
+ return;
102
+ }
103
+ if (val.handleType === 'add') {
104
+ stationSlot.addPallet(val);
105
+ }
106
+ else if (val.handleType === 'remove') {
107
+ stationSlot.removeAllPallet();
108
+ }
109
+ }
110
+ }
@@ -1,10 +1,18 @@
1
+ /**
2
+ * @Author : YourName
3
+ * @File : createGlass.ts
4
+ * @Date : 2026/04/07
5
+ * @Desc. : 创建玻璃质感背景的工厂函数
6
+ */
1
7
  import { Box } from 'leafer';
2
8
  export interface IGlassConfig {
3
9
  x?: number;
4
10
  y?: number;
5
11
  width: number;
6
12
  height: number;
7
- cornerRadius?: number;
13
+ cornerRadius?: number | number[];
14
+ origin?: 'center' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
15
+ around?: 'center' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
8
16
  }
9
17
  /**
10
18
  * 创建具有磨砂玻璃效果的 Box 容器
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @Author : YourName
3
+ * @File : createGlass.ts
4
+ * @Date : 2026/04/07
5
+ * @Desc. : 创建玻璃质感背景的工厂函数
6
+ */
7
+ import { Box } from 'leafer';
8
+ import { Texture } from '../shapes/Texture';
9
+ /**
10
+ * 创建具有磨砂玻璃效果的 Box 容器
11
+ */
12
+ export function createGlass(config) {
13
+ const { x, y, width, height, cornerRadius = 10, origin = 'center', around = 'center' } = config;
14
+ const glassBox = new Box({
15
+ x,
16
+ y,
17
+ width,
18
+ height,
19
+ cornerRadius,
20
+ origin,
21
+ around,
22
+ hittable: false,
23
+ className: 'Glass',
24
+ fill: {
25
+ type: 'linear',
26
+ from: 'top-left',
27
+ to: 'bottom-right',
28
+ stops: [
29
+ { offset: 0, color: 'rgba(255, 255, 255, 0.8)' },
30
+ { offset: 1, color: 'rgba(239, 251, 255, 0.5)' }
31
+ ]
32
+ },
33
+ shadow: {
34
+ blur: 3,
35
+ color: 'rgba(0,0,0,0.3)'
36
+ },
37
+ stroke: 'rgba(255, 255, 255, 0.3)',
38
+ strokeWidth: 1
39
+ });
40
+ // 添加纹理
41
+ glassBox.add(Texture({
42
+ width,
43
+ height,
44
+ cornerRadius,
45
+ effect: 'VerticalBar',
46
+ opacity: 0.08,
47
+ scale: 0.015,
48
+ rotation: 45
49
+ }));
50
+ return glassBox;
51
+ }
@@ -1,3 +1,10 @@
1
- import { ILayer } from '../../types';
2
- import { ModelAbs } from '../abstract/ModelAbs';
1
+ /**
2
+ * @Author : TanRui
3
+ * @WeChat : Tan578853789
4
+ * @File : createModel.ts
5
+ * @Date : 2026/02/13
6
+ * @Desc. : 设备模型工厂函数
7
+ */
8
+ import { type ILayer } from '@/types';
9
+ import type { ModelAbs } from '../abstract/ModelAbs';
3
10
  export declare function createModel(config: ILayer): ModelAbs;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @Author : TanRui
3
+ * @WeChat : Tan578853789
4
+ * @File : createModel.ts
5
+ * @Date : 2026/02/13
6
+ * @Desc. : 设备模型工厂函数
7
+ */
8
+ import { EnumModel } from '@/types';
9
+ import { MachineTool } from '../models/MachineTool';
10
+ import { LoadingStation } from '../models/LoadingStation';
11
+ import { MarkingMachine } from '../models/MarkingMachine';
12
+ import { CleaningMachine } from '../models/CleaningMachine';
13
+ import { SingleJointRobot } from '../models/SingleJointRobot';
14
+ import { Rail } from '../models/Rail';
15
+ import { ResourceStore } from '../models/ResourceStore';
16
+ export function createModel(config) {
17
+ switch (config.className) {
18
+ case EnumModel.MACHINE_TOOL:
19
+ return new MachineTool(config);
20
+ case EnumModel.LOADING_STATION:
21
+ return new LoadingStation(config);
22
+ case EnumModel.MARKING_MACHINE:
23
+ return new MarkingMachine(config);
24
+ case EnumModel.CLEANING_MACHINE:
25
+ return new CleaningMachine(config);
26
+ case EnumModel.SINGLE_JOINT_ROBOT:
27
+ return new SingleJointRobot(config);
28
+ case EnumModel.RAIL:
29
+ return new Rail(config);
30
+ case EnumModel.RESOURCE_STORE:
31
+ return new ResourceStore(config);
32
+ default:
33
+ throw new Error('Unsupported model className');
34
+ }
35
+ }
@@ -1,9 +1,17 @@
1
- import { Canvas, IShadowEffect } from 'leafer';
1
+ /**
2
+ * @Author : TanRui
3
+ * @WeChat : Tan578853789
4
+ * @File : createShadow.ts
5
+ * @Date : 2026/04/02
6
+ * @Desc. : 创建阴影效果的 Canvas 实例(leaferJs 的原生阴影性能差,官方推荐使用 canvas 实现阴影效果)
7
+ * @Intro. : 该工厂函数用于创建一个带有阴影效果的 Canvas 实例,适用于设备模型的阴影渲染。通过配置阴影的大小、模糊程度和颜色,实现逼真的阴影效果,增强设备模型的视觉层次感和立体感。
8
+ */
9
+ import { Canvas, type IShadowEffect } from 'leafer';
2
10
  export interface IShadow {
3
11
  width: number;
4
12
  height: number;
5
- cornerRadius?: number;
6
- shadow?: IShadowEffect | IShadowEffect[];
7
- innerShadow?: IShadowEffect | IShadowEffect[];
13
+ cornerRadius?: number | number[];
14
+ shadow?: IShadowEffect | IShadowEffect[] | null;
15
+ innerShadow?: IShadowEffect | IShadowEffect[] | null;
8
16
  }
9
17
  export declare function createShadow(options: IShadow): Canvas;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @Author : TanRui
3
+ * @WeChat : Tan578853789
4
+ * @File : createShadow.ts
5
+ * @Date : 2026/04/02
6
+ * @Desc. : 创建阴影效果的 Canvas 实例(leaferJs 的原生阴影性能差,官方推荐使用 canvas 实现阴影效果)
7
+ * @Intro. : 该工厂函数用于创建一个带有阴影效果的 Canvas 实例,适用于设备模型的阴影渲染。通过配置阴影的大小、模糊程度和颜色,实现逼真的阴影效果,增强设备模型的视觉层次感和立体感。
8
+ */
9
+ import { Canvas, Pen } from 'leafer';
10
+ export function createShadow(options) {
11
+ const shadowSize = {
12
+ width: options.width * 0.1, // 阴影宽度为元素宽度的 10%
13
+ height: options.height * 0.1 // 阴影高度为元素高度的 10%
14
+ };
15
+ const { width = 0, height = 0, cornerRadius = 0, shadow = [
16
+ {
17
+ x: 0,
18
+ y: 0,
19
+ blur: shadowSize.width,
20
+ color: 'rgba(0,0,0,0.3)'
21
+ }
22
+ ], innerShadow = [
23
+ {
24
+ x: shadowSize.width,
25
+ y: shadowSize.height,
26
+ blur: shadowSize.width,
27
+ color: 'rgba(0,0,0,0.5)'
28
+ },
29
+ {
30
+ x: -shadowSize.width,
31
+ y: -shadowSize.height,
32
+ blur: shadowSize.width,
33
+ color: 'rgba(255,255,255,0.5)'
34
+ }
35
+ ] } = options;
36
+ const ui = new Canvas({
37
+ className: 'ShadowCanvas',
38
+ pixelRatio: devicePixelRatio,
39
+ width,
40
+ height,
41
+ hittable: false
42
+ });
43
+ const pen = new Pen();
44
+ pen.setStyle({
45
+ fill: 'rgba(255,255,255,0)',
46
+ shadow: shadow ?? undefined,
47
+ innerShadow: innerShadow ?? undefined
48
+ });
49
+ pen.roundRect(0, 0, width, height, cornerRadius);
50
+ ui.draw(pen);
51
+ return ui;
52
+ }
@@ -1,3 +1,10 @@
1
+ /**
2
+ * @Author : TanRui
3
+ * @WeChat : Tan578853789
4
+ * @File : createText.ts
5
+ * @Date : 2026/04/08
6
+ * @Desc. : 创建文本组件(Text)的工厂函数
7
+ */
1
8
  import { Text } from 'leafer';
2
9
  export interface CreateTextOptions {
3
10
  name?: string;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @Author : TanRui
3
+ * @WeChat : Tan578853789
4
+ * @File : createText.ts
5
+ * @Date : 2026/04/08
6
+ * @Desc. : 创建文本组件(Text)的工厂函数
7
+ */
8
+ import { Text } from 'leafer';
9
+ /**
10
+ * 创建自适应文本(支持动态字号、换行、省略号)
11
+ */
12
+ export function createText(options) {
13
+ const { name, width, height, className = 'CreateText', fill = 'rgba(0,0,0,0.2)', fontSize, fontWeight = 'black', hittable = false } = options;
14
+ if (!name) {
15
+ return new Text({ text: '', width, height, visible: 0 });
16
+ }
17
+ // 动态计算字体大小(基于字符数)
18
+ const charCount = name.length;
19
+ const maxFontSize = Math.min(height * 0.8, width * 0.5);
20
+ const minFontSize = 12;
21
+ // 估算所需字号
22
+ const estimatedFontSize = width / (charCount * 0.6);
23
+ let autoFontSize = Math.min(maxFontSize, estimatedFontSize);
24
+ // 如果估算字号小于最小值,则固定为最小值,并启用换行+省略
25
+ if (autoFontSize < minFontSize) {
26
+ autoFontSize = minFontSize;
27
+ }
28
+ return new Text({
29
+ hittable,
30
+ className,
31
+ text: name,
32
+ textAlign: 'center',
33
+ verticalAlign: 'middle',
34
+ fontSize: fontSize || autoFontSize,
35
+ fontWeight,
36
+ fill,
37
+ width,
38
+ height,
39
+ lineHeight: {
40
+ type: 'percent',
41
+ value: 1
42
+ },
43
+ textOverflow: '...', // 启用省略号
44
+ textWrap: 'break' // 强制断词
45
+ });
46
+ }
@@ -0,0 +1,14 @@
1
+ import type { ICleaningMachineConfig, ICleaningMachineOperating } from '@/types';
2
+ import { Box } from 'leafer';
3
+ import { ModelAbs } from '../abstract/ModelAbs';
4
+ /**
5
+ * 清洗机
6
+ */
7
+ export declare class CleaningMachine extends ModelAbs<ICleaningMachineConfig> {
8
+ private light;
9
+ private progress;
10
+ private entrance;
11
+ private stationSlotGroup;
12
+ protected createUi(): Box;
13
+ protected operating(data: ICleaningMachineOperating): void;
14
+ }