@jnrs/lingshu-smart 2.2.8 → 2.2.10

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,277 +0,0 @@
1
- import { EnumModel } from '@/types';
2
- import { ref, computed, onMounted } from 'vue';
3
- import { uuidv4 } from '@jnrs/shared/uuid';
4
- import LingshuSmartPreview from '@/components/preview/index.vue';
5
- // 预览组件实例
6
- const lingshuSmartPreviewRef = ref();
7
- // 当前方案 ID
8
- const currentCaseId = ref();
9
- // 当前方案数据
10
- const currentCase = computed(() => {
11
- return lingshuSmartPreviewRef.value?.currentCase;
12
- });
13
- /**
14
- * 加载方案列表数据
15
- * @param requestId 请求数据ID,即输入框输入的值(按需)
16
- */
17
- const loadCases = async (requestId) => {
18
- // 此处模拟异步请求,生产环境请按需替换为后端 API
19
- const res = await fetch(`/json/cases.json?requestId=${requestId}`);
20
- await new Promise((resolve) => setTimeout(resolve, 500));
21
- const data = await res.json();
22
- return data.data;
23
- };
24
- // 点击事件
25
- const onTap = (layer, data) => {
26
- console.log('点击 parent', layer, '点击 target', data);
27
- };
28
- // 右键点击事件
29
- const onMenuTap = (layer, data) => {
30
- console.log('右键点击 parent', layer, '右键点击 target', data);
31
- };
32
- // 拖拽结束事件
33
- const onDragEnd = (layer, data) => {
34
- console.log('拖拽结束 parent', layer, '拖拽结束 target', data);
35
- };
36
- // 设备运行
37
- const operating = (data) => {
38
- lingshuSmartPreviewRef.value?.operating(data);
39
- };
40
- // websocket 消息处理
41
- const onMessage = (rawMessage) => {
42
- console.log('接收ws数据:', rawMessage);
43
- // 校验必要字段
44
- if (!rawMessage?.type || !rawMessage?.payload) {
45
- console.warn('无效的 WebSocket 消息格式', rawMessage);
46
- return;
47
- }
48
- const type = rawMessage.type;
49
- const payload = rawMessage.payload;
50
- if (type === 'update') {
51
- // 根据原始数据处理设备运行数据
52
- switch (payload.type) {
53
- case 'Pallet':
54
- if (payload.addType && payload.addId) {
55
- // 新增资源
56
- operating({
57
- className: payload.addType,
58
- id: payload.addId,
59
- rawData: payload,
60
- resource: {
61
- resourceType: payload.type,
62
- name: payload.name,
63
- color: payload.status === 3 ? 'green' : '#424242',
64
- index: payload.addSiteNumber,
65
- handleType: 'add',
66
- rawData: payload
67
- }
68
- });
69
- }
70
- if (payload.removeType && payload.removeId) {
71
- // 删除资源
72
- operating({
73
- className: payload.removeType,
74
- id: payload.removeId,
75
- rawData: payload,
76
- resource: {
77
- resourceType: payload.type,
78
- index: payload.removeSiteNumber,
79
- handleType: 'remove',
80
- rawData: payload
81
- }
82
- });
83
- }
84
- break;
85
- case 'MachineTool':
86
- operating({
87
- className: EnumModel.MACHINE_TOOL,
88
- id: payload.id,
89
- rawData: payload,
90
- light: {
91
- color: payload.status === 2 ? 'green' : '#424242',
92
- blinking: payload.status !== 2,
93
- rotating: payload.status === 2
94
- },
95
- progress: {
96
- percent: payload.percent,
97
- textContent: payload.status === 2 ? '运行中' : '待机中'
98
- },
99
- entrance: {
100
- isIn: payload.isIn,
101
- isOut: payload.isOut
102
- },
103
- stationRotatable: payload.stationRotatable
104
- });
105
- break;
106
- case 'ResourceStore':
107
- operating({
108
- className: EnumModel.RESOURCE_STORE,
109
- id: payload.id,
110
- rawData: payload,
111
- light: {
112
- color: payload.status === 2 ? 'green' : '#424242',
113
- blinking: payload.status === 2
114
- }
115
- });
116
- break;
117
- case 'SingleJointRobot':
118
- operating({
119
- className: EnumModel.SINGLE_JOINT_ROBOT,
120
- id: payload.id,
121
- rawData: payload,
122
- light: {
123
- color: payload.status === 2 ? 'green' : '#424242',
124
- blinking: payload.status === 2
125
- },
126
- x: payload.x,
127
- r: payload.r
128
- });
129
- break;
130
- }
131
- }
132
- };
133
- onMounted(() => {
134
- const VIEW_PATH = '/preview/';
135
- if (location.pathname.includes(VIEW_PATH)) {
136
- currentCaseId.value = location.pathname.split(VIEW_PATH)[1];
137
- }
138
- // MOCK 服务器发送的 websocket 数据,实际需和后端确认数据格式
139
- setTimeout(() => {
140
- onMessage({
141
- traceId: uuidv4(),
142
- type: 'update',
143
- payload: {
144
- id: '75fb136f-bb81-4348-b53f-b9ba56f1816b',
145
- type: 'MachineTool',
146
- status: 2,
147
- percent: 0.8,
148
- isIn: true,
149
- isOut: false,
150
- stationRotatable: true
151
- }
152
- });
153
- onMessage({
154
- traceId: uuidv4(),
155
- type: 'update',
156
- payload: {
157
- id: 'b37075e3-25a3-4adf-937d-f9e94d27d917',
158
- type: 'SingleJointRobot',
159
- status: 2,
160
- x: 800,
161
- r: 45
162
- }
163
- });
164
- onMessage({
165
- traceId: uuidv4(),
166
- type: 'update',
167
- payload: {
168
- id: '35cd0433-2587-4dce-8e08-13e397b5eb3d',
169
- type: 'ResourceStore',
170
- status: 2
171
- }
172
- });
173
- onMessage({
174
- traceId: uuidv4(),
175
- type: 'update',
176
- payload: {
177
- type: 'Pallet',
178
- name: 'P111',
179
- status: 3,
180
- addType: 'MachineTool',
181
- addId: '75fb136f-bb81-4348-b53f-b9ba56f1816b',
182
- addSiteNumber: 2,
183
- removeId: null,
184
- removeType: null,
185
- removeSiteNumber: null
186
- }
187
- });
188
- setTimeout(() => {
189
- onMessage({
190
- traceId: uuidv4(),
191
- type: 'update',
192
- payload: {
193
- id: '75fb136f-bb81-4348-b53f-b9ba56f1816b',
194
- type: 'MachineTool',
195
- percent: 1,
196
- isIn: true,
197
- isOut: true,
198
- stationRotatable: false
199
- }
200
- });
201
- onMessage({
202
- traceId: uuidv4(),
203
- type: 'update',
204
- payload: {
205
- type: 'Pallet',
206
- name: 'P111',
207
- status: 2,
208
- addType: 'ResourceStore',
209
- addId: '35cd0433-2587-4dce-8e08-13e397b5eb3d',
210
- addSiteNumber: 3,
211
- removeId: '75fb136f-bb81-4348-b53f-b9ba56f1816b',
212
- removeType: 'MachineTool',
213
- removeSiteNumber: 2
214
- }
215
- });
216
- onMessage({
217
- traceId: uuidv4(),
218
- type: 'update',
219
- payload: {
220
- id: 'b37075e3-25a3-4adf-937d-f9e94d27d917',
221
- type: 'SingleJointRobot',
222
- x: 800,
223
- r: 145
224
- }
225
- });
226
- }, 1500);
227
- }, 1500);
228
- });
229
- debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
230
- const __VLS_ctx = {
231
- ...{},
232
- ...{},
233
- };
234
- let __VLS_components;
235
- let __VLS_directives;
236
- __VLS_asFunctionalElement(__VLS_intrinsics.div, __VLS_intrinsics.div)({
237
- ...{ class: "main" },
238
- });
239
- __VLS_asFunctionalElement(__VLS_intrinsics.div, __VLS_intrinsics.div)({
240
- ...{ class: "head" },
241
- });
242
- (__VLS_ctx.currentCase?.title);
243
- // @ts-ignore
244
- [currentCase,];
245
- /** @type {[typeof LingshuSmartPreview, typeof LingshuSmartPreview, ]} */ ;
246
- // @ts-ignore
247
- const __VLS_0 = __VLS_asFunctionalComponent(LingshuSmartPreview, new LingshuSmartPreview({
248
- ref: "lingshuSmartPreviewRef",
249
- actions: ({
250
- loadCases: __VLS_ctx.loadCases,
251
- onTap: __VLS_ctx.onTap,
252
- onMenuTap: __VLS_ctx.onMenuTap,
253
- onDragEnd: __VLS_ctx.onDragEnd
254
- }),
255
- caseUuid: (__VLS_ctx.currentCaseId),
256
- }));
257
- const __VLS_1 = __VLS_0({
258
- ref: "lingshuSmartPreviewRef",
259
- actions: ({
260
- loadCases: __VLS_ctx.loadCases,
261
- onTap: __VLS_ctx.onTap,
262
- onMenuTap: __VLS_ctx.onMenuTap,
263
- onDragEnd: __VLS_ctx.onDragEnd
264
- }),
265
- caseUuid: (__VLS_ctx.currentCaseId),
266
- }, ...__VLS_functionalComponentArgsRest(__VLS_0));
267
- /** @type {typeof __VLS_ctx.lingshuSmartPreviewRef} */ ;
268
- var __VLS_4 = {};
269
- // @ts-ignore
270
- [loadCases, onTap, onMenuTap, onDragEnd, currentCaseId, lingshuSmartPreviewRef,];
271
- var __VLS_2;
272
- /** @type {__VLS_StyleScopedClasses['main']} */ ;
273
- /** @type {__VLS_StyleScopedClasses['head']} */ ;
274
- // @ts-ignore
275
- var __VLS_5 = __VLS_4;
276
- const __VLS_export = (await import('vue')).defineComponent({});
277
- export default {};
@@ -1,3 +0,0 @@
1
- export { useDataStore } from './useDataStore';
2
- export { useEditorStore } from './useEditorStore';
3
- export { useAppStore } from './useAppStore';
@@ -1,78 +0,0 @@
1
- /**
2
- * @Author : TanRui
3
- * @WeChat : Tan578853789
4
- * @File : useAppStore.ts
5
- * @Date : 2026/03/20
6
- * @Desc. : 用于预览页面:当前方案状态
7
- */
8
- import { defineStore } from 'pinia';
9
- import { ref } from 'vue';
10
- import { AppController } from '@/controller/AppController';
11
- import { useDataStore } from './useDataStore';
12
- export const useAppStore = defineStore('@jnrs/lingshu-smart/app', () => {
13
- const sharedStore = useDataStore();
14
- const currentCase = ref();
15
- // 容器实例
16
- let appContainer = null;
17
- /**
18
- * 初始化容器(引擎实例)
19
- * @param options 容器配置
20
- * @param caseUuid 当前方案 UUID
21
- */
22
- const initContainer = (options, caseUuid) => {
23
- if (appContainer) {
24
- console.warn('❌ Container already initialized');
25
- return;
26
- }
27
- appContainer = new AppController(options);
28
- console.log('✅ AppController Initialized');
29
- currentCase.value = sharedStore.cases?.find((c) => c.uuid === caseUuid);
30
- if (currentCase.value) {
31
- for (const layer of currentCase.value.layers) {
32
- appContainer.addModel(layer);
33
- }
34
- appContainer.setTree(currentCase.value.scene);
35
- }
36
- else {
37
- console.warn('⚠️ 当前方案不存在', { cases: sharedStore.cases }, { caseUuid });
38
- }
39
- };
40
- /**
41
- * resize 容器
42
- */
43
- const resizeContainer = () => {
44
- if (!appContainer) {
45
- console.warn('❌ resizeContainer failed: AppController not initialized');
46
- return;
47
- }
48
- appContainer.setZoom();
49
- };
50
- /**
51
- * 销毁容器
52
- */
53
- const destroyContainer = () => {
54
- if (!appContainer) {
55
- console.warn('❌ destroyContainer failed: AppController not initialized');
56
- return;
57
- }
58
- appContainer.destroy();
59
- appContainer = null;
60
- };
61
- /**
62
- * 设备运转
63
- */
64
- const operating = (data) => {
65
- if (!appContainer) {
66
- console.warn('❌ operating failed: AppController not initialized');
67
- return;
68
- }
69
- appContainer.operating(data);
70
- };
71
- return {
72
- currentCase,
73
- initContainer,
74
- resizeContainer,
75
- destroyContainer,
76
- operating
77
- };
78
- });
@@ -1,116 +0,0 @@
1
- /**
2
- * @Author : TanRui
3
- * @WeChat : Tan578853789
4
- * @File : useDataStore.ts
5
- * @Date : 2026/03/23
6
- * @Desc. : 设备列表、方案列表、当前方案、当前方案的场景、当前方案的图层列表、当前图层状态管理
7
- */
8
- import { ref } from 'vue';
9
- import { defineStore } from 'pinia';
10
- import { isICaseArray, isICase } from '@/utils/type-guards';
11
- import { uuidv4 } from '@jnrs/shared/uuid';
12
- import { cloneDeep } from '@jnrs/shared/lodash';
13
- import { CASE_INIT } from '@/constants/options';
14
- import { EQUIPMENTS_MENU } from '@/assets/data/editor_preset_menu';
15
- export const useDataStore = defineStore('@jnrs/lingshu-smart/data', () => {
16
- // 设备菜单
17
- const equipmentsMenu = cloneDeep(EQUIPMENTS_MENU);
18
- // 方案列表
19
- const cases = ref();
20
- const casesLoading = ref(false);
21
- /**
22
- * 更新方案列表
23
- */
24
- const updateCases = (data) => {
25
- if (!data) {
26
- cases.value = [];
27
- return;
28
- }
29
- // 类型守卫:校验数据结构
30
- if (isICaseArray(data)) {
31
- cases.value = data;
32
- }
33
- else {
34
- const errorMsg = '运行 updateCases 函数时参数校验失败:发现非法的 ICase, ILayer 或 IScene 结构';
35
- console.error(errorMsg, data);
36
- throw new Error(errorMsg);
37
- }
38
- };
39
- /**
40
- * 切换当前方案
41
- */
42
- const selectCase = (uuid) => {
43
- if (!cases.value)
44
- return;
45
- const target = cases.value.find((c) => c.uuid === uuid);
46
- if (!target)
47
- return;
48
- cases.value.forEach((c) => {
49
- c.isActive = c.uuid === uuid;
50
- });
51
- };
52
- /**
53
- * 添加方案
54
- */
55
- const addCase = (data) => {
56
- // 如果方案列表不存在,则初始化
57
- if (!cases.value) {
58
- cases.value = [];
59
- }
60
- const uuid = uuidv4();
61
- if (data) {
62
- // 类型守卫:校验数据结构
63
- if (isICase(data)) {
64
- const newCase = cloneDeep(data);
65
- newCase.uuid = uuid; // 重置方案 uuid 防止冲突
66
- newCase.isActive = false; // 重置方案 isActive 状态防止冲突
67
- cases.value.push(newCase);
68
- }
69
- else {
70
- const errorMsg = '运行 addCase 函数时参数校验失败:发现非法的 ICase, ILayer 或 IScene 结构';
71
- console.error(errorMsg, data);
72
- throw new Error(errorMsg);
73
- }
74
- }
75
- else {
76
- const newCase = cloneDeep(CASE_INIT);
77
- newCase.uuid = uuid;
78
- newCase.title = `方案${uuid.slice(0, 8)}`;
79
- cases.value.push(newCase);
80
- }
81
- };
82
- /**
83
- * 删除方案
84
- */
85
- const removeCase = (uuid) => {
86
- if (!cases.value)
87
- return;
88
- const index = cases.value.findIndex((c) => c.uuid === uuid);
89
- if (index === -1)
90
- return;
91
- cases.value.splice(index, 1);
92
- };
93
- /**
94
- * 清空方案列表
95
- */
96
- const clearCases = () => {
97
- cases.value = [];
98
- };
99
- return {
100
- // getters
101
- casesLoading,
102
- equipmentsMenu,
103
- cases,
104
- // actions
105
- updateCases,
106
- selectCase,
107
- addCase,
108
- removeCase,
109
- clearCases
110
- };
111
- }, {
112
- persist: {
113
- storage: localStorage,
114
- pick: ['cases']
115
- }
116
- });