@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,263 +0,0 @@
1
- /**
2
- * @Author : TanRui
3
- * @WeChat : Tan578853789
4
- * @File : useEditorStore.ts
5
- * @Date : 2026/01/21
6
- * @Desc. : 用于编辑器页面:设备列表、方案列表、当前方案、当前方案的场景、当前方案的图层列表、当前图层状态管理
7
- */
8
- import { uuidv4 } from '@jnrs/shared/uuid';
9
- import { debounce, cloneDeep } from '@jnrs/shared/lodash';
10
- import { defineStore } from 'pinia';
11
- import { computed, watch } from 'vue';
12
- import { DEFAULT_LAYER } from '@/constants/options';
13
- import { AppController } from '@/controller/AppController';
14
- import { EditorController } from '@/controller/EditorController';
15
- import { transPercentAndPixel } from '@/utils';
16
- import { useDataStore } from './useDataStore';
17
- export const useEditorStore = defineStore('@jnrs/lingshu-smart/editor', () => {
18
- const sharedStore = useDataStore();
19
- // APP 容器实例
20
- let appContainer = null;
21
- // 编辑器实例
22
- let editorManager = null;
23
- // 当前选择的方案
24
- const currentCase = computed(() => {
25
- return sharedStore.cases?.find((c) => c.isActive) || null;
26
- });
27
- // 当前方案场景
28
- const scene = computed(() => {
29
- if (!currentCase.value)
30
- return null;
31
- return currentCase.value.scene;
32
- });
33
- // 当前方案图层列表
34
- const layers = computed(() => {
35
- if (!currentCase.value)
36
- return [];
37
- return currentCase.value.layers;
38
- });
39
- // 当前选择的图层
40
- const currentLayer = computed(() => {
41
- if (!currentCase.value)
42
- return null;
43
- return layers.value.find((d) => d.selected) || null;
44
- });
45
- /**
46
- * 初始化容器(引擎实例)
47
- */
48
- const initContainer = (options) => {
49
- if (appContainer) {
50
- console.warn('❌ Container already initialized');
51
- return;
52
- }
53
- appContainer = new AppController(options);
54
- console.log('✅ AppController Initialized');
55
- if (options.appEditable) {
56
- initEditor();
57
- }
58
- updateScene();
59
- };
60
- /**
61
- * 修改场景
62
- */
63
- const updateScene = debounce(() => {
64
- if (!appContainer) {
65
- console.warn('❌ updateScene failed: AppController not initialized');
66
- return;
67
- }
68
- if (scene.value) {
69
- console.log('🖥 updateScene...');
70
- appContainer.setTree(scene.value);
71
- }
72
- // 场景更新后重新渲染全部图层
73
- renderLayers();
74
- }, 300);
75
- /**
76
- * 渲染全部图层
77
- */
78
- const renderLayers = debounce(() => {
79
- if (!appContainer) {
80
- console.warn('❌ renderLayers failed: AppController not initialized');
81
- return;
82
- }
83
- // 先清空所有图层
84
- appContainer.clearAll();
85
- // 如果当前方案存在,则渲染当前方案
86
- if (currentCase.value) {
87
- const uuid = currentLayer.value?.uuid;
88
- for (const layer of layers.value) {
89
- appContainer.addModel(layer);
90
- if (editorManager && layer.uuid === uuid) {
91
- editorManager.selectEquipment(`#${uuid}`);
92
- }
93
- }
94
- }
95
- else {
96
- // 如果当前方案不存在,则初始化容器 UI
97
- appContainer.setTree(undefined);
98
- }
99
- console.log('🖌 renderLayers...');
100
- }, 250);
101
- /**
102
- * 销毁容器
103
- */
104
- const destroyContainer = () => {
105
- if (appContainer) {
106
- appContainer.destroy();
107
- appContainer = null;
108
- console.log('✅ AppController Destroyed');
109
- }
110
- if (editorManager) {
111
- editorManager.destroy();
112
- editorManager = null;
113
- console.log('✅ EditorController Destroyed');
114
- }
115
- };
116
- /**
117
- * resize 容器
118
- */
119
- const resizeContainer = () => {
120
- if (!appContainer) {
121
- console.error('Cannot resize Container: AppController missing');
122
- return;
123
- }
124
- appContainer.setZoom();
125
- };
126
- /**
127
- * 初始化编辑器
128
- */
129
- const initEditor = () => {
130
- if (!appContainer) {
131
- console.error('Cannot init Editor: AppController missing');
132
- return;
133
- }
134
- editorManager = new EditorController({
135
- container: appContainer,
136
- onSelected: (ids) => {
137
- const uuid = ids[0];
138
- layers.value.forEach((layer) => {
139
- if (layer.uuid === uuid) {
140
- layer.selected = true;
141
- }
142
- else {
143
- layer.selected = false;
144
- }
145
- });
146
- },
147
- onRotate: (rotation) => {
148
- const layer = currentLayer.value;
149
- if (layer) {
150
- layer.rotation = rotation;
151
- }
152
- },
153
- onScale: (width) => {
154
- const layer = currentLayer.value;
155
- if (layer && layer.width && layer.height) {
156
- layer.scale = Number((width / layer.width).toFixed(2));
157
- }
158
- },
159
- onMove: (x, y) => {
160
- const layer = currentLayer.value;
161
- if (layer && layer.width && layer.height) {
162
- layer.x = x;
163
- layer.y = y;
164
- layer.percentX = transPercentAndPixel(x, scene.value?.width, 3, true);
165
- layer.percentY = transPercentAndPixel(y, scene.value?.height, 3, true);
166
- }
167
- }
168
- });
169
- console.log('✅ EditorController Initialized');
170
- };
171
- /**
172
- * 更新图层属性 (修改当前 UI 需要立即响应属性,如宽高、位置、旋转、缩放等)
173
- */
174
- const updateLayer = (layer) => {
175
- if (!appContainer)
176
- return;
177
- const model = appContainer.findOne(`#${layer.uuid}`);
178
- if (model) {
179
- model.set(layer);
180
- console.log('🎨 updateLayer');
181
- }
182
- };
183
- /**
184
- * 单独重绘某个图层(重绘为了修改子 UI 的显示)
185
- * @param layer 要重绘的图层对象
186
- */
187
- const rerenderLayer = debounce((layer) => {
188
- if (editorManager) {
189
- console.log('♻️ rerenderLayer...');
190
- editorManager.rerenderModel(layer);
191
- }
192
- }, 500);
193
- /**
194
- * 添加图层(图层)到当前方案
195
- */
196
- const addLayer = (layer) => {
197
- if (!currentCase.value) {
198
- console.warn('❌ addLayer failed: currentCase not initialized');
199
- return;
200
- }
201
- const uuid = layer.uuid || uuidv4();
202
- const zIndex = layers.value.length + 1;
203
- const newLayer = {
204
- ...cloneDeep(DEFAULT_LAYER), // 使用cloneDeep防止展开运算符的浅拷贝无法处理嵌套对象,导致污染初始值
205
- ...cloneDeep(layer),
206
- uuid,
207
- zIndex,
208
- rawData: {
209
- id: uuid
210
- }
211
- };
212
- // 直接 push 到响应式数组
213
- currentCase.value.layers.push(newLayer);
214
- // 添加后重绘
215
- if (!appContainer) {
216
- console.warn('❌ addLayer failed: appContainer not initialized');
217
- return;
218
- }
219
- appContainer.addModel(newLayer);
220
- };
221
- /**
222
- * 切换选中图层,选中对应的 UI
223
- */
224
- const selectLayer = (uuid) => {
225
- if (editorManager) {
226
- const isCurrentLayer = currentLayer.value?.uuid === uuid;
227
- editorManager.selectEquipment(isCurrentLayer ? undefined : `#${uuid}`);
228
- }
229
- };
230
- // ==================== 监听器 ====================
231
- // 监听场景配置变化
232
- watch(scene, () => {
233
- if (appContainer) {
234
- updateScene();
235
- }
236
- }, { deep: true });
237
- // 监听当前选中图层的变化,更新图形 UI
238
- watch(currentLayer, (layer) => {
239
- if (layer) {
240
- updateLayer(layer);
241
- rerenderLayer(layer);
242
- }
243
- }, { deep: true });
244
- return {
245
- // Getters
246
- currentCase,
247
- scene,
248
- layers,
249
- currentLayer,
250
- // Actions
251
- initContainer,
252
- resizeContainer,
253
- destroyContainer,
254
- initEditor,
255
- // 场景
256
- updateScene,
257
- // 当前图层
258
- addLayer,
259
- selectLayer,
260
- updateLayer,
261
- renderLayers
262
- };
263
- });
@@ -1,2 +0,0 @@
1
- import { EnumTag } from './index';
2
- import { PointerEvent } from 'leafer';
@@ -1 +0,0 @@
1
- import {} from './enums';
@@ -1 +0,0 @@
1
- import { EnumResourceType, EnumComponent } from '../enums';
@@ -1 +0,0 @@
1
- import { EnumResourceType } from '../enums';
@@ -1,46 +0,0 @@
1
- // 步骤操作类型
2
- export var EnumStepType;
3
- (function (EnumStepType) {
4
- EnumStepType["UNDO"] = "Undo";
5
- EnumStepType["REDO"] = "Redo";
6
- })(EnumStepType || (EnumStepType = {}));
7
- // 设备标签枚举
8
- export var EnumTag;
9
- (function (EnumTag) {
10
- EnumTag["TRANSPORT"] = "\u642C\u8FD0\u8BBE\u5907";
11
- EnumTag["MACHINE"] = "\u673A\u5E8A";
12
- EnumTag["CLEANING"] = "\u6E05\u6D17\u673A";
13
- EnumTag["STATION"] = "\u88C5\u8F7D\u7AD9";
14
- EnumTag["STORAGE"] = "\u5E93";
15
- EnumTag["OTHER"] = "\u5176\u4ED6";
16
- })(EnumTag || (EnumTag = {}));
17
- // 设备类型枚举
18
- export var EnumModel;
19
- (function (EnumModel) {
20
- EnumModel["SINGLE_JOINT_ROBOT"] = "SingleJointRobot";
21
- EnumModel["DOUBLE_GRIPPER_ROBOT"] = "DoubleGripperRobot";
22
- EnumModel["RGV"] = "Rgv";
23
- EnumModel["MACHINE_TOOL"] = "MachineTool";
24
- EnumModel["MARKING_MACHINE"] = "MarkingMachine";
25
- EnumModel["CLEANING_MACHINE"] = "CleaningMachine";
26
- EnumModel["LOADING_STATION"] = "LoadingStation";
27
- EnumModel["PALLET_STORAGE"] = "PalletStorage";
28
- EnumModel["TOOL_STORAGE"] = "ToolStorage";
29
- EnumModel["BUFFER_DOCK"] = "BufferDock";
30
- EnumModel["GROUND_RAIL"] = "GroundRail";
31
- EnumModel["FOLLOWING_TUGGER"] = "FollowingTugger";
32
- EnumModel["RAIL"] = "Rail";
33
- EnumModel["RESOURCE_STORE"] = "ResourceStore";
34
- })(EnumModel || (EnumModel = {}));
35
- // 组件类型枚举
36
- export var EnumComponent;
37
- (function (EnumComponent) {
38
- EnumComponent["STATION_SLOT"] = "StationSlot";
39
- EnumComponent["RESOURCE"] = "Resource";
40
- })(EnumComponent || (EnumComponent = {}));
41
- // 资源类型枚举
42
- export var EnumResourceType;
43
- (function (EnumResourceType) {
44
- EnumResourceType["PALLET"] = "Pallet";
45
- EnumResourceType["TOOL"] = "Tool";
46
- })(EnumResourceType || (EnumResourceType = {}));
@@ -1,28 +0,0 @@
1
- /**
2
- * @Author : TanRui
3
- * @WeChat : Tan578853789
4
- * @File : guards.ts
5
- * @Date : 2026/04/07
6
- * @Desc. : 类型守卫函数
7
- */
8
- import { EnumModel } from './index';
9
- // 是否为机床
10
- export function isMachineTool(layer) {
11
- return layer?.className === EnumModel.MACHINE_TOOL;
12
- }
13
- // 是否拥有工位组配置
14
- export function hasStationSlotGroup(layer) {
15
- return (layer?.className === EnumModel.MACHINE_TOOL ||
16
- layer?.className === EnumModel.MARKING_MACHINE ||
17
- layer?.className === EnumModel.CLEANING_MACHINE ||
18
- layer?.className === EnumModel.LOADING_STATION ||
19
- layer?.className === EnumModel.RESOURCE_STORE);
20
- }
21
- // 是否拥有夹具切换配置
22
- export function hasFixtureChange(layer) {
23
- return layer?.className === EnumModel.SINGLE_JOINT_ROBOT;
24
- }
25
- // 是否为轨道配置
26
- export function isRail(layer) {
27
- return layer?.className === EnumModel.RAIL;
28
- }
@@ -1,8 +0,0 @@
1
- export * from './enums';
2
- export * from './app.types';
3
- export * from './base.types';
4
- export * from './models/config.types';
5
- export * from './models/operating.types';
6
- export * from './components/config.types';
7
- export * from './components/operating.types';
8
- export * from './guards';
@@ -1 +0,0 @@
1
- import { EnumModel, EnumTag, EnumResourceType } from '../enums';
@@ -1 +0,0 @@
1
- import { EnumModel, EnumResourceType } from '../enums';
@@ -1,64 +0,0 @@
1
- /**
2
- * @Author : TanRui
3
- * @WeChat : Tan578853789
4
- * @File : ComponentAbs.ts
5
- * @Date : 2026/02/13
6
- * @Desc. : 抽象类:子组件(Model-View 分离)
7
- */
8
- import { UI } from 'leafer';
9
- import { cloneDeep } from '@jnrs/shared/lodash';
10
- export class ComponentAbs {
11
- _ui = null;
12
- _config;
13
- _initialized = false;
14
- constructor(options) {
15
- this._config = cloneDeep(options);
16
- }
17
- get ui() {
18
- if (!this._ui) {
19
- throw new Error('访问 ui 失败:UI 实例未创建,请先调用 init() 方法');
20
- }
21
- return this._ui;
22
- }
23
- get config() {
24
- return this._config;
25
- }
26
- // 宽度计算 - 50%(中心点)
27
- get width_05() {
28
- return this.config.width * 0.5;
29
- }
30
- // 高度计算 - 50%(中心点)
31
- get height_05() {
32
- return this.config.height * 0.5;
33
- }
34
- // 设备操作
35
- operating(data) { }
36
- // 初始化 UI(必须在 setEventHandler 之前调用)
37
- init() {
38
- if (this._initialized) {
39
- console.warn('元素已经初始化,重复初始化');
40
- return this;
41
- }
42
- this._ui = this.createUi();
43
- this._initialized = true;
44
- return this;
45
- }
46
- // 处理设备操作
47
- handleOperation = (data) => {
48
- this.operating(data);
49
- };
50
- // 销毁 UI 和事件绑定
51
- destroyUI() {
52
- if (!this._initialized) {
53
- console.warn('销毁失败,元素未初始化');
54
- return;
55
- }
56
- this.ui.destroy();
57
- this._initialized = false;
58
- }
59
- // 销毁
60
- destroy() {
61
- this.destroyUI();
62
- this._ui = null;
63
- }
64
- }
@@ -1,119 +0,0 @@
1
- /**
2
- * @Author : TanRui
3
- * @WeChat : Tan578853789
4
- * @File : ModelAbs.ts
5
- * @Date : 2026/02/13
6
- * @Desc. : 抽象类:设备
7
- * @Intro. : Model-View 分离架构
8
- */
9
- import { UI, PointerEvent, DragEvent } from 'leafer';
10
- import { cloneDeep, debounce } from '@jnrs/shared/lodash';
11
- const DEBOUNCE_TIME = 300; // 防抖时间 300ms
12
- export class ModelAbs {
13
- _ui = null;
14
- _config;
15
- eventHandler = null;
16
- _initialized = false;
17
- constructor(options) {
18
- this._config = cloneDeep(options);
19
- }
20
- get ui() {
21
- if (!this._ui) {
22
- throw new Error('访问 ui 失败:UI 实例未创建,请先调用 init() 方法');
23
- }
24
- return this._ui;
25
- }
26
- get config() {
27
- return this._config;
28
- }
29
- // 宽度计算 - 50%(中心点)
30
- get width_05() {
31
- return this.config.width * 0.5;
32
- }
33
- get width_02() {
34
- return this.config.width * 0.2;
35
- }
36
- get width_08() {
37
- return this.config.width * 0.8;
38
- }
39
- // 高度计算 - 50%(中心点)
40
- get height_05() {
41
- return this.config.height * 0.5;
42
- }
43
- // 初始化 UI(必须在 setEventHandler 之前调用)
44
- init() {
45
- if (this._initialized) {
46
- console.warn('元素已经初始化,重复初始化');
47
- return this;
48
- }
49
- this._ui = this.createUi();
50
- this._initialized = true;
51
- return this;
52
- }
53
- // 处理设备操作
54
- handleOperation = (data) => {
55
- this.operating(data);
56
- };
57
- // 赋值函数,用于判断是否注册交互事件
58
- shouldHandleInteraction(e, selfEnabled) {
59
- const isTargetSelf = e.target === this.ui;
60
- // 情况1禁止注册: hitSelf 为 false,且点击的是自身
61
- if (!this.config.hitSelf && isTargetSelf)
62
- return false;
63
- // 情况2禁止注册: 点击、右击、移动等交互的是自身,但自身不可点击、右击、移动等
64
- if (isTargetSelf && !selfEnabled)
65
- return false;
66
- return true;
67
- }
68
- // 点击事件回调
69
- tapCallback = debounce((e) => {
70
- if (!this.shouldHandleInteraction(e, this.config.clickable))
71
- return;
72
- this.eventHandler?.onTap?.(this.config, e.target.data);
73
- }, DEBOUNCE_TIME);
74
- // 右键点击事件回调
75
- menuTapCallback = debounce((e) => {
76
- if (!this.shouldHandleInteraction(e, this.config.menuClickable))
77
- return;
78
- this.eventHandler?.onMenuTap?.(this.config, e.target.data);
79
- }, DEBOUNCE_TIME);
80
- // 拖拽事件回调
81
- dragCallback = (e) => {
82
- if (!this.shouldHandleInteraction(e, this.config.draggable))
83
- return;
84
- this.eventHandler?.onDragEnd?.(this.config, e.target.data);
85
- };
86
- // 注册事件(事件委托模式)
87
- setEventHandler(handler) {
88
- // 不可交互时不注册自定义事件(不在 UI 上设置 hittable 属性,防止编辑模式下无法选中设备)
89
- if (!this.config.hittable)
90
- return;
91
- this.eventHandler = handler;
92
- if (Object.hasOwn(handler, 'onTap')) {
93
- this.ui.on(PointerEvent.TAP, this.tapCallback);
94
- }
95
- if (Object.hasOwn(handler, 'onMenuTap')) {
96
- this.ui.on(PointerEvent.MENU_TAP, this.menuTapCallback);
97
- }
98
- if (Object.hasOwn(handler, 'onDragEnd')) {
99
- this.ui.on(DragEvent.END, this.dragCallback);
100
- }
101
- }
102
- // 销毁 UI 和事件绑定
103
- destroyUI() {
104
- if (!this._initialized) {
105
- console.warn('销毁失败,元素未初始化');
106
- return;
107
- }
108
- this.ui.off(PointerEvent.TAP, this.tapCallback);
109
- this.ui.off(PointerEvent.MENU_TAP, this.menuTapCallback);
110
- this.ui.off(DragEvent.END, this.dragCallback);
111
- this.ui.destroy();
112
- this._initialized = false;
113
- }
114
- // 销毁
115
- destroy() {
116
- this.destroyUI();
117
- this._ui = null;
118
- }
119
- }
@@ -1,83 +0,0 @@
1
- /**
2
- * @Author : TanRui
3
- * @WeChat : Tan578853789
4
- * @File : Entrance.ts
5
- * @Date : 2025/01/18
6
- * @desc. : 设备入口
7
- */
8
- import { Box } from 'leafer';
9
- import {} from '@/types';
10
- import { ComponentAbs } from '../abstract/ComponentAbs';
11
- export class Entrance extends ComponentAbs {
12
- constructor(options) {
13
- const DEFAULTS = {
14
- x: 0,
15
- y: 0,
16
- width: 120,
17
- height: 30,
18
- isIn: true,
19
- isOut: false
20
- };
21
- super({ ...DEFAULTS, ...options });
22
- }
23
- get ChannelSize() {
24
- const w = this.config.width * 0.2;
25
- return w > 35 ? w : 35;
26
- }
27
- createUi() {
28
- const { x, y, width } = this.config;
29
- const main = new Box({
30
- className: 'Entrance',
31
- hittable: false,
32
- x,
33
- y,
34
- width,
35
- around: 'top',
36
- overflow: 'hide',
37
- children: [
38
- this.renderChannel('outChannel', '下料', this.ChannelSize),
39
- this.renderChannel('inChannel', '上料', this.config.width - this.ChannelSize)
40
- ]
41
- });
42
- return main;
43
- }
44
- renderChannel(className, text, x) {
45
- return {
46
- className,
47
- tag: 'Box',
48
- x,
49
- y: 0,
50
- around: 'top',
51
- visible: false,
52
- children: [
53
- {
54
- tag: 'Polygon',
55
- points: [0, 0, 0, 10, this.ChannelSize / 2, this.ChannelSize / 2, this.ChannelSize, 10, this.ChannelSize, 0],
56
- animation: {
57
- keyframes: [{ fill: '#65DB79' }, { fill: '#009866', scaleY: 1.1 }],
58
- duration: 0.3,
59
- swing: true
60
- }
61
- },
62
- {
63
- tag: 'Text',
64
- text: text,
65
- fill: '#333',
66
- fontSize: 12,
67
- fontWeight: 'bold',
68
- textAlign: 'center',
69
- y: -2,
70
- width: this.ChannelSize
71
- }
72
- ]
73
- };
74
- }
75
- operating(val) {
76
- this.ui.findOne('.inChannel')?.set({
77
- visible: val.isIn
78
- });
79
- this.ui.findOne('.outChannel')?.set({
80
- visible: val.isOut
81
- });
82
- }
83
- }