@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.
- package/dist/App.vue.d.ts +1 -2
- package/dist/assets/data/editor_default_setting.d.ts +1 -8
- package/dist/assets/data/editor_preset_menu.d.ts +1 -8
- package/dist/components/editor/ControlBar/CaseManger.vue.d.ts +15 -3
- package/dist/components/editor/ControlBar/CaseTitleEdit.vue.d.ts +411 -2
- package/dist/components/editor/ControlBar/ExportImportDialog.vue.d.ts +2 -3
- package/dist/components/editor/ControlBar/MainButton.vue.d.ts +2 -3
- package/dist/components/editor/ControlBar/StepButton.vue.d.ts +1 -2
- package/dist/components/editor/ControlBar/StepRecordVisualizer.vue.d.ts +1 -2
- package/dist/components/editor/DrawingBoard.vue.d.ts +1 -2
- package/dist/components/editor/MenuCard/Equipments.vue.d.ts +1 -2
- package/dist/components/editor/MenuCard/Layers.vue.d.ts +1 -2
- package/dist/components/editor/MenuCard/index.vue.d.ts +1 -2
- package/dist/components/editor/OptionCard/Equipment/Base.vue.d.ts +1 -2
- package/dist/components/editor/OptionCard/Equipment/DataSets.vue.d.ts +1 -2
- package/dist/components/editor/OptionCard/Equipment/Interaction.vue.d.ts +1 -2
- package/dist/components/editor/OptionCard/Equipment/Position.vue.d.ts +1 -2
- package/dist/components/editor/OptionCard/Equipment/StationSlotGroup.vue.d.ts +1 -2
- package/dist/components/editor/OptionCard/Equipment/index.vue.d.ts +1 -2
- package/dist/components/editor/OptionCard/Equipment/models/MachineTool.vue.d.ts +1 -2
- package/dist/components/editor/OptionCard/Equipment/models/Rail.vue.d.ts +1 -2
- package/dist/components/editor/OptionCard/Equipment/models/SingleJointRobot.vue.d.ts +2 -0
- package/dist/components/editor/OptionCard/Scene/Background.vue.d.ts +1 -2
- package/dist/components/editor/OptionCard/Scene/index.vue.d.ts +1 -2
- package/dist/components/editor/OptionCard/index.vue.d.ts +1 -2
- package/dist/components/editor/index.vue.d.ts +13 -4
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +27281 -4
- package/dist/components/preview/index.vue.d.ts +5 -6
- package/dist/composables/useStepRecord.d.ts +4 -12
- package/dist/constants/options.d.ts +1 -8
- package/dist/controller/AppController.d.ts +3 -10
- package/dist/controller/EditorController.d.ts +2 -9
- package/dist/index.js +1 -1
- package/dist/json/cases.json +577 -20
- package/dist/locales/i18next.d.ts +1 -1
- package/dist/locales/index.d.ts +2 -2
- package/dist/locales/index.js +13 -3
- package/dist/main.d.ts +0 -3
- package/dist/playground/EditPageDemo.vue.d.ts +1 -2
- package/dist/playground/ViewPageDemo.vue.d.ts +27 -2
- package/dist/stores/useAppStore.d.ts +5 -12
- package/dist/stores/useDataStore.d.ts +11 -18
- package/dist/stores/useEditorStore.d.ts +20 -27
- package/dist/types/app.types.d.ts +1 -1
- package/dist/types/base.types.d.ts +1 -1
- package/dist/types/components/config.types.d.ts +1 -1
- package/dist/types/components/operating.types.d.ts +1 -1
- package/dist/types/enums.d.ts +1 -1
- package/dist/types/guards.d.ts +5 -12
- package/dist/types/index.d.ts +2 -2
- package/dist/types/models/config.types.d.ts +49 -47
- package/dist/types/models/operating.types.d.ts +53 -53
- package/dist/ui/abstract/ComponentAbs.d.ts +2 -9
- package/dist/ui/abstract/ModelAbs.d.ts +2 -10
- package/dist/ui/components/Entrance.d.ts +1 -8
- package/dist/ui/components/Light.d.ts +1 -8
- package/dist/ui/components/Progress.d.ts +1 -8
- package/dist/ui/components/Resource.d.ts +1 -8
- package/dist/ui/components/StationSlot.d.ts +1 -23
- package/dist/ui/components/StationSlotGroup.d.ts +1 -8
- package/dist/ui/factories/createGlass.d.ts +0 -6
- package/dist/ui/factories/createModel.d.ts +2 -9
- package/dist/ui/factories/createShadow.d.ts +1 -9
- package/dist/ui/factories/createText.d.ts +0 -7
- package/dist/ui/models/CleaningMachine.d.ts +1 -1
- package/dist/ui/models/DoubleJointRobot.d.ts +19 -20
- package/dist/ui/models/LoadingStation.d.ts +1 -1
- package/dist/ui/models/MachineTool.d.ts +1 -1
- package/dist/ui/models/MarkingMachine.d.ts +1 -1
- package/dist/ui/models/Rail.d.ts +1 -1
- package/dist/ui/models/ResourceStore.d.ts +1 -1
- package/dist/ui/models/SingleJointRobot.d.ts +3 -3
- package/dist/ui/shapes/NamePlate.d.ts +0 -7
- package/dist/ui/shapes/ScrewHole.d.ts +0 -7
- package/dist/ui/shapes/Texture.d.ts +1 -8
- package/dist/ui/utils/attr.d.ts +2 -9
- package/dist/utils/type-guards.d.ts +1 -1
- package/package.json +3 -3
- package/dist/App.vue.js +0 -30
- package/dist/assets/data/editor_default.d.ts +0 -16
- package/dist/assets/data/editor_default.js +0 -59
- package/dist/assets/data/editor_default_setting.js +0 -58
- package/dist/assets/data/editor_preset.d.ts +0 -9
- package/dist/assets/data/editor_preset.js +0 -51
- package/dist/assets/data/editor_preset_menu.js +0 -290
- package/dist/components/editor/ControlBar/CaseManger.vue.js +0 -465
- package/dist/components/editor/ControlBar/CaseTitleEdit.vue.js +0 -108
- package/dist/components/editor/ControlBar/ExportImportDialog.vue.js +0 -280
- package/dist/components/editor/ControlBar/MainButton.vue.js +0 -183
- package/dist/components/editor/ControlBar/StepButton.vue.js +0 -147
- package/dist/components/editor/ControlBar/StepRecordVisualizer.vue.js +0 -98
- package/dist/components/editor/DrawingBoard.vue.js +0 -31
- package/dist/components/editor/MenuCard/Equipments.vue.js +0 -129
- package/dist/components/editor/MenuCard/Layers.vue.js +0 -201
- package/dist/components/editor/MenuCard/index.vue.js +0 -84
- package/dist/components/editor/OptionCard/Equipment/Base.vue.js +0 -96
- package/dist/components/editor/OptionCard/Equipment/Binds.vue.d.ts +0 -3
- package/dist/components/editor/OptionCard/Equipment/Binds.vue.js +0 -443
- package/dist/components/editor/OptionCard/Equipment/Bot.vue.d.ts +0 -3
- package/dist/components/editor/OptionCard/Equipment/Bot.vue.js +0 -81
- package/dist/components/editor/OptionCard/Equipment/DataSets.vue.js +0 -304
- package/dist/components/editor/OptionCard/Equipment/DockStore.vue.d.ts +0 -3
- package/dist/components/editor/OptionCard/Equipment/DockStore.vue.js +0 -597
- package/dist/components/editor/OptionCard/Equipment/Interaction.vue.js +0 -287
- package/dist/components/editor/OptionCard/Equipment/Position.backup.vue.d.ts +0 -3
- package/dist/components/editor/OptionCard/Equipment/Position.backup.vue.js +0 -440
- package/dist/components/editor/OptionCard/Equipment/Position.vue.js +0 -436
- package/dist/components/editor/OptionCard/Equipment/StationSlotGroup.vue.js +0 -1131
- package/dist/components/editor/OptionCard/Equipment/Store.vue.d.ts +0 -3
- package/dist/components/editor/OptionCard/Equipment/Store.vue.js +0 -453
- package/dist/components/editor/OptionCard/Equipment/Trailer.vue.d.ts +0 -3
- package/dist/components/editor/OptionCard/Equipment/Trailer.vue.js +0 -1109
- package/dist/components/editor/OptionCard/Equipment/index.vue.js +0 -100
- package/dist/components/editor/OptionCard/Equipment/models/MachineTool.vue.js +0 -99
- package/dist/components/editor/OptionCard/Equipment/models/Rail.vue.js +0 -225
- package/dist/components/editor/OptionCard/Equipment/models/SingleGripperRobot.vue.d.ts +0 -3
- package/dist/components/editor/OptionCard/Equipment/models/SingleGripperRobot.vue.js +0 -99
- package/dist/components/editor/OptionCard/Scene/Background.vue.js +0 -543
- package/dist/components/editor/OptionCard/Scene/index.vue.js +0 -200
- package/dist/components/editor/OptionCard/index.vue.js +0 -73
- package/dist/components/editor/index.vue.js +0 -156
- package/dist/components/preview/index.vue.js +0 -104
- package/dist/composables/useStepRecord.js +0 -135
- package/dist/constants/options.js +0 -55
- package/dist/controller/AppController.js +0 -168
- package/dist/controller/EditorController.js +0 -173
- package/dist/locales/en.js +0 -5
- package/dist/locales/i18next.js +0 -6
- package/dist/locales/zhCn.js +0 -5
- package/dist/main.js +0 -13
- package/dist/playground/EditPageDemo.vue.js +0 -57
- package/dist/playground/ViewPageDemo.vue.js +0 -277
- package/dist/stores/index.js +0 -3
- package/dist/stores/useAppStore.js +0 -78
- package/dist/stores/useDataStore.js +0 -116
- package/dist/stores/useEditorStore.js +0 -263
- package/dist/types/app.types.js +0 -2
- package/dist/types/base.types.js +0 -1
- package/dist/types/components/config.types.js +0 -1
- package/dist/types/components/operating.types.js +0 -1
- package/dist/types/enums.js +0 -46
- package/dist/types/guards.js +0 -28
- package/dist/types/index.js +0 -8
- package/dist/types/models/config.types.js +0 -1
- package/dist/types/models/operating.types.js +0 -1
- package/dist/ui/abstract/ComponentAbs.js +0 -64
- package/dist/ui/abstract/ModelAbs.js +0 -119
- package/dist/ui/components/Entrance.js +0 -83
- package/dist/ui/components/Light.js +0 -167
- package/dist/ui/components/Progress.js +0 -84
- package/dist/ui/components/Resource.js +0 -70
- package/dist/ui/components/StationSlot.js +0 -207
- package/dist/ui/components/StationSlotGroup.js +0 -110
- package/dist/ui/factories/createGlass.js +0 -51
- package/dist/ui/factories/createModel.js +0 -35
- package/dist/ui/factories/createShadow.js +0 -52
- package/dist/ui/factories/createText.js +0 -46
- package/dist/ui/models/CleaningMachine.js +0 -141
- package/dist/ui/models/DoubleJointRobot.js +0 -545
- package/dist/ui/models/LoadingStation.js +0 -167
- package/dist/ui/models/MachineTool.js +0 -184
- package/dist/ui/models/MarkingMachine.js +0 -148
- package/dist/ui/models/Rail.js +0 -117
- package/dist/ui/models/ResourceStore.js +0 -101
- package/dist/ui/models/SingleBot.d.ts +0 -20
- package/dist/ui/models/SingleBot.js +0 -202
- package/dist/ui/models/SingleGripperRobot.d.ts +0 -19
- package/dist/ui/models/SingleGripperRobot.js +0 -272
- package/dist/ui/models/SingleJointRobot.js +0 -346
- package/dist/ui/shapes/NamePlate.js +0 -85
- package/dist/ui/shapes/ScrewHole.js +0 -57
- package/dist/ui/shapes/Texture.js +0 -51
- package/dist/ui/utils/attr.js +0 -50
- package/dist/utils/index.js +0 -92
- package/dist/utils/type-guards.js +0 -105
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Author : TanRui
|
|
3
|
-
* @WeChat : Tan578853789
|
|
4
|
-
* @File : options.ts
|
|
5
|
-
* @Date : 2026/01/21
|
|
6
|
-
* @Desc. : 编辑页面的初始值配置
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* 新方案默认值
|
|
10
|
-
*/
|
|
11
|
-
export const CASE_INIT = {
|
|
12
|
-
uuid: '',
|
|
13
|
-
title: '',
|
|
14
|
-
isActive: false,
|
|
15
|
-
layers: [],
|
|
16
|
-
scene: {
|
|
17
|
-
width: 1920,
|
|
18
|
-
height: 1080,
|
|
19
|
-
zoomType: 'fit',
|
|
20
|
-
fill: {
|
|
21
|
-
type: 'solid',
|
|
22
|
-
color: '#000',
|
|
23
|
-
opacity: 1,
|
|
24
|
-
stops: []
|
|
25
|
-
},
|
|
26
|
-
texture: ''
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* 新图层默认值
|
|
31
|
-
*/
|
|
32
|
-
export const DEFAULT_LAYER = {
|
|
33
|
-
rawData: {
|
|
34
|
-
id: ''
|
|
35
|
-
},
|
|
36
|
-
uuid: '',
|
|
37
|
-
equipmentName: '',
|
|
38
|
-
width: 0,
|
|
39
|
-
height: 0,
|
|
40
|
-
x: 0,
|
|
41
|
-
y: 0,
|
|
42
|
-
percentX: 0,
|
|
43
|
-
percentY: 0,
|
|
44
|
-
rotation: 0,
|
|
45
|
-
scale: 1,
|
|
46
|
-
zIndex: 1,
|
|
47
|
-
// 交互状态
|
|
48
|
-
visible: true,
|
|
49
|
-
clickable: true,
|
|
50
|
-
menuClickable: true,
|
|
51
|
-
draggable: false,
|
|
52
|
-
// 编辑状态
|
|
53
|
-
editable: true,
|
|
54
|
-
selected: false
|
|
55
|
-
};
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Author : TanRui
|
|
3
|
-
* @WeChat : Tan578853789
|
|
4
|
-
* @File : AppController.ts
|
|
5
|
-
* @Date : 2026/02/05
|
|
6
|
-
* @Desc. : 主画布、模型容器控制器
|
|
7
|
-
*/
|
|
8
|
-
import { createModel } from '@/ui/factories/createModel';
|
|
9
|
-
import { App, Box } from 'leafer';
|
|
10
|
-
const INIT_TREE_CONFIG = {
|
|
11
|
-
width: window.innerWidth,
|
|
12
|
-
height: window.innerHeight,
|
|
13
|
-
fill: undefined,
|
|
14
|
-
zoomType: 'fit'
|
|
15
|
-
};
|
|
16
|
-
export class AppController {
|
|
17
|
-
app;
|
|
18
|
-
treeBoxUI = null; // 主容器
|
|
19
|
-
modelsMap; // 模型容器映射,key 为 uuid,value 为模型实例
|
|
20
|
-
businessMap; // 业务模型映射,key 为 `${className}_${businessId}`,value 为模型实例
|
|
21
|
-
appEditable; // 是否可编辑
|
|
22
|
-
actions; // 事件处理
|
|
23
|
-
constructor(options = {}) {
|
|
24
|
-
const { appDomId, autoStart = true, appEditable = false, actions = {} } = options;
|
|
25
|
-
this.appEditable = appEditable;
|
|
26
|
-
this.actions = actions;
|
|
27
|
-
this.app = new App({
|
|
28
|
-
view: appDomId || window,
|
|
29
|
-
start: autoStart,
|
|
30
|
-
ground: {},
|
|
31
|
-
tree: { type: appEditable ? 'design' : 'game' },
|
|
32
|
-
editor: appEditable ? {} : undefined,
|
|
33
|
-
maxFPS: 60,
|
|
34
|
-
fill: '#424242',
|
|
35
|
-
pointer: {
|
|
36
|
-
preventDefault: true,
|
|
37
|
-
preventDefaultMenu: true
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
const treeBoxUI = new Box({
|
|
41
|
-
...INIT_TREE_CONFIG,
|
|
42
|
-
id: 'treeBoxUI',
|
|
43
|
-
stroke: appEditable ? { type: 'solid', color: 'rgb(242, 195, 79)' } : null
|
|
44
|
-
});
|
|
45
|
-
this.treeBoxUI = treeBoxUI;
|
|
46
|
-
this.app.tree.add(treeBoxUI);
|
|
47
|
-
this.modelsMap = new Map();
|
|
48
|
-
this.businessMap = new Map();
|
|
49
|
-
this.setZoom();
|
|
50
|
-
}
|
|
51
|
-
// 启动/重启引擎
|
|
52
|
-
start() {
|
|
53
|
-
this.app.start();
|
|
54
|
-
}
|
|
55
|
-
// 销毁引擎,默认采用异步销毁,不会立即执行
|
|
56
|
-
destroy() {
|
|
57
|
-
this.clearAll();
|
|
58
|
-
this.app.destroy();
|
|
59
|
-
}
|
|
60
|
-
// 控制视图的缩放
|
|
61
|
-
setZoom(zoomType = 'fit', duration = 0.5) {
|
|
62
|
-
requestAnimationFrame(() => {
|
|
63
|
-
if (zoomType === 'fit') {
|
|
64
|
-
const padding = this.appEditable ? [30, 10, 10, 30] : 0;
|
|
65
|
-
this.app.tree.zoom('fit', padding, false, duration);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
this.app.tree.zoom(zoomType, 0, false, duration);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
// 修改 tree 配置,不传参数则重置为默认配置
|
|
73
|
-
setTree(data) {
|
|
74
|
-
if (data) {
|
|
75
|
-
this.treeBoxUI?.set({
|
|
76
|
-
width: data.width,
|
|
77
|
-
height: data.height,
|
|
78
|
-
fill: data.fill
|
|
79
|
-
});
|
|
80
|
-
this.setZoom(data.zoomType);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
this.setTree(INIT_TREE_CONFIG);
|
|
84
|
-
this.setZoom();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
// tree 层查找元素,返回数组
|
|
88
|
-
findAll(condition) {
|
|
89
|
-
return this.treeBoxUI?.find(condition) || [];
|
|
90
|
-
}
|
|
91
|
-
// tree 层查找一个元素,返回匹配到的第一个元素
|
|
92
|
-
findOne(condition) {
|
|
93
|
-
return this.treeBoxUI?.findOne(condition);
|
|
94
|
-
}
|
|
95
|
-
// tree 层移除指定的子元素
|
|
96
|
-
removeOne(condition) {
|
|
97
|
-
this.treeBoxUI?.remove(condition);
|
|
98
|
-
}
|
|
99
|
-
// tree 层清空所有元素(移除 + 销毁)
|
|
100
|
-
clearAll() {
|
|
101
|
-
this.modelsMap.clear();
|
|
102
|
-
this.businessMap.clear();
|
|
103
|
-
this.treeBoxUI?.clear();
|
|
104
|
-
}
|
|
105
|
-
// 根据 uuid 移除模型
|
|
106
|
-
removeModelById(uuid) {
|
|
107
|
-
const model = this.modelsMap.get(uuid);
|
|
108
|
-
if (model) {
|
|
109
|
-
model.destroyUI();
|
|
110
|
-
this.modelsMap.delete(uuid);
|
|
111
|
-
const businessId = model.config.rawData?.id;
|
|
112
|
-
if (businessId) {
|
|
113
|
-
this.businessMap.delete(businessId);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
// 根据类型和配置添加模型
|
|
118
|
-
addModel(modelConfig) {
|
|
119
|
-
const model = createModel(modelConfig);
|
|
120
|
-
// 存储模型绑定事件
|
|
121
|
-
if (this.actions) {
|
|
122
|
-
model.init().setEventHandler({
|
|
123
|
-
onTap: (layer, data) => {
|
|
124
|
-
this.actions.onTap?.(layer, data);
|
|
125
|
-
},
|
|
126
|
-
onMenuTap: (layer, e) => {
|
|
127
|
-
this.actions.onMenuTap?.(layer, e);
|
|
128
|
-
},
|
|
129
|
-
onDragEnd: (layer, e) => {
|
|
130
|
-
this.actions.onDragEnd?.(layer, e);
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
// 添加到树
|
|
135
|
-
if (this.treeBoxUI && model.ui) {
|
|
136
|
-
this.treeBoxUI.add(model.ui);
|
|
137
|
-
}
|
|
138
|
-
const uuid = modelConfig.uuid;
|
|
139
|
-
const businessId = modelConfig.rawData?.id;
|
|
140
|
-
// 存储模型引用
|
|
141
|
-
if (uuid) {
|
|
142
|
-
this.modelsMap.set(uuid, model);
|
|
143
|
-
}
|
|
144
|
-
// 存储业务模型引用
|
|
145
|
-
if (businessId) {
|
|
146
|
-
this.businessMap.set(`${modelConfig.className}_${businessId}`, model);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
// 移除并重新添加模型
|
|
150
|
-
rerenderModel(modelConfig) {
|
|
151
|
-
if (modelConfig.uuid) {
|
|
152
|
-
this.removeModelById(modelConfig.uuid);
|
|
153
|
-
}
|
|
154
|
-
this.addModel(modelConfig);
|
|
155
|
-
}
|
|
156
|
-
// 模型操作
|
|
157
|
-
operating(data) {
|
|
158
|
-
const layer = this.businessMap.get(`${data.className}_${data.id}`);
|
|
159
|
-
if (!layer) {
|
|
160
|
-
console.warn('模型操作失败: 模型未匹配到', {
|
|
161
|
-
className: data.className,
|
|
162
|
-
id: data.id
|
|
163
|
-
});
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
layer.handleOperation(data);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Author : TanRui
|
|
3
|
-
* @WeChat : Tan578853789
|
|
4
|
-
* @File : EditorController.ts
|
|
5
|
-
* @Date : 2025/02/26
|
|
6
|
-
* @Desc. : 图形编辑类
|
|
7
|
-
*/
|
|
8
|
-
import { EditorEvent, EditorRotateEvent, EditorScaleEvent, EditorMoveEvent } from 'leafer';
|
|
9
|
-
import { Ruler } from 'leafer-x-ruler';
|
|
10
|
-
import { DotMatrix } from 'leafer-x-dot-matrix';
|
|
11
|
-
const DEFAULT_ZOOM_MIN = 0.1;
|
|
12
|
-
const DEFAULT_ZOOM_MAX = 10;
|
|
13
|
-
const RULER_THEME_NAME = 'ruler-dark';
|
|
14
|
-
const RULER_SIZE = 20;
|
|
15
|
-
const DOT_MATRIX_COLOR = '#000';
|
|
16
|
-
const DOT_MATRIX_SIZE = 1;
|
|
17
|
-
const TARGET_DOT_MATRIX_PIXEL = 20;
|
|
18
|
-
/**
|
|
19
|
-
* EditorController 类负责管理图形编辑功能,包括设备的选择、旋转和缩放等操作。它通过监听编辑器的事件来更新当前选中的设备,并提供方法来设置缩放范围、标尺和点阵等功能。
|
|
20
|
-
* @param {string} options.container - AppController 对象
|
|
21
|
-
* @param {number} options.zoomMin - 最小缩放比例,默认为 0.1
|
|
22
|
-
* @param {number} options.zoomMax - 最大缩放比例,默认为 10
|
|
23
|
-
* @param {Function} options.onSelected - 设备选中事件的回调函数
|
|
24
|
-
* @param {Function} options.onRotate - 设备旋转事件的回调函数,参数为旋转角度
|
|
25
|
-
* @param {Function} options.onScale - 设备缩放事件的回调函数,参数为缩放比例
|
|
26
|
-
*/
|
|
27
|
-
export class EditorController {
|
|
28
|
-
container;
|
|
29
|
-
editor;
|
|
30
|
-
onSelected;
|
|
31
|
-
onRotate;
|
|
32
|
-
onScale;
|
|
33
|
-
onMove;
|
|
34
|
-
constructor(options) {
|
|
35
|
-
const { container, zoomMin = DEFAULT_ZOOM_MIN, zoomMax = DEFAULT_ZOOM_MAX } = options;
|
|
36
|
-
if (zoomMin >= zoomMax) {
|
|
37
|
-
throw new Error('zoomMin must be less than zoomMax');
|
|
38
|
-
}
|
|
39
|
-
const app = container.app;
|
|
40
|
-
app.config.zoom = {
|
|
41
|
-
disabled: false,
|
|
42
|
-
min: zoomMin,
|
|
43
|
-
max: zoomMax
|
|
44
|
-
};
|
|
45
|
-
try {
|
|
46
|
-
addRuler(app);
|
|
47
|
-
addDotMatrix(app);
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
console.error('Failed to initialize plugins:', error);
|
|
51
|
-
}
|
|
52
|
-
this.container = container;
|
|
53
|
-
this.editor = app.editor;
|
|
54
|
-
this.onSelected = options.onSelected;
|
|
55
|
-
this.onRotate = options.onRotate;
|
|
56
|
-
this.onScale = options.onScale;
|
|
57
|
-
this.onMove = options.onMove;
|
|
58
|
-
const editorConfig = {
|
|
59
|
-
multipleSelect: false, // 多选
|
|
60
|
-
boxSelect: false, // 框选
|
|
61
|
-
lockRatio: true, // 锁定宽高比例
|
|
62
|
-
moveable: true, // 可移动
|
|
63
|
-
resizeable: true, // 编辑大小
|
|
64
|
-
rotateable: true, // 旋转
|
|
65
|
-
skewable: false, // 倾斜
|
|
66
|
-
rotateGap: 15 // 旋转角度间隔
|
|
67
|
-
};
|
|
68
|
-
Object.assign(this.editor.config, editorConfig);
|
|
69
|
-
this.addEvent();
|
|
70
|
-
}
|
|
71
|
-
// 选择设备
|
|
72
|
-
selectEquipment(condition) {
|
|
73
|
-
if (!condition)
|
|
74
|
-
return this.editor.cancel();
|
|
75
|
-
const target = this.container.findAll(condition);
|
|
76
|
-
if (target) {
|
|
77
|
-
this.editor.select(target);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
// 重新渲染设备并进行选中
|
|
81
|
-
rerenderModel(modelConfig) {
|
|
82
|
-
if (!this.container) {
|
|
83
|
-
console.warn('❌ rerenderModel failed: container not initialized');
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
this.container.rerenderModel(modelConfig);
|
|
87
|
-
this.selectEquipment(`#${modelConfig.uuid}`);
|
|
88
|
-
}
|
|
89
|
-
// 设置监听事件
|
|
90
|
-
addEvent() {
|
|
91
|
-
// 选中设备
|
|
92
|
-
this.editor.on(EditorEvent.SELECT, (e) => {
|
|
93
|
-
try {
|
|
94
|
-
const ids = e.editor.list.map((d) => d.id);
|
|
95
|
-
this.onSelected?.(ids);
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
console.error('Error in SELECT event handler:', error);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
// 旋转设备
|
|
102
|
-
this.editor.on(EditorRotateEvent.ROTATE, (e) => {
|
|
103
|
-
try {
|
|
104
|
-
const { rotation } = e.target;
|
|
105
|
-
if (typeof rotation === 'number') {
|
|
106
|
-
this.onRotate?.(rotation);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
console.error('Error in ROTATE event handler:', error);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
// 缩放设备
|
|
114
|
-
this.editor.on(EditorScaleEvent.SCALE, (e) => {
|
|
115
|
-
try {
|
|
116
|
-
const { width, height, scale } = e.target;
|
|
117
|
-
if (typeof width === 'number' &&
|
|
118
|
-
typeof height === 'number' &&
|
|
119
|
-
(typeof scale === 'number' || (typeof scale === 'object' && scale.x !== undefined && scale.y !== undefined))) {
|
|
120
|
-
const scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
121
|
-
const scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
122
|
-
this.onScale?.(width * scaleX, height * scaleY);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
catch (error) {
|
|
126
|
-
console.error('Error in SCALE event handler:', error);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
// 移动设备
|
|
130
|
-
this.editor.on(EditorMoveEvent.MOVE, (e) => {
|
|
131
|
-
try {
|
|
132
|
-
const { x, y } = e.target;
|
|
133
|
-
if (typeof x === 'number' && typeof y === 'number') {
|
|
134
|
-
this.onMove?.(Math.round(x), Math.round(y));
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
catch (error) {
|
|
138
|
-
console.error('Error in MOVE event handler:', error);
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
// 销毁事件
|
|
143
|
-
destroy() {
|
|
144
|
-
this.editor.off(EditorEvent.SELECT);
|
|
145
|
-
this.editor.off(EditorRotateEvent.ROTATE);
|
|
146
|
-
this.editor.off(EditorScaleEvent.SCALE);
|
|
147
|
-
this.editor.off(EditorMoveEvent.MOVE);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
// 添加标尺插件
|
|
151
|
-
function addRuler(app) {
|
|
152
|
-
const ruler = new Ruler(app, {
|
|
153
|
-
enabled: true,
|
|
154
|
-
ruleSize: RULER_SIZE,
|
|
155
|
-
unit: 'px'
|
|
156
|
-
});
|
|
157
|
-
ruler.addTheme(RULER_THEME_NAME, {
|
|
158
|
-
backgroundColor: '#333',
|
|
159
|
-
textColor: '#ccc',
|
|
160
|
-
borderColor: '#888',
|
|
161
|
-
highlightColor: 'rgba(125,111,239,.8)'
|
|
162
|
-
});
|
|
163
|
-
ruler.changeTheme(RULER_THEME_NAME);
|
|
164
|
-
}
|
|
165
|
-
// 添加点阵插件
|
|
166
|
-
function addDotMatrix(app) {
|
|
167
|
-
const dotMatrix = new DotMatrix(app, {
|
|
168
|
-
dotColor: DOT_MATRIX_COLOR,
|
|
169
|
-
dotSize: DOT_MATRIX_SIZE,
|
|
170
|
-
targetDotMatrixPixel: TARGET_DOT_MATRIX_PIXEL
|
|
171
|
-
});
|
|
172
|
-
dotMatrix.enableDotMatrix(true);
|
|
173
|
-
}
|
package/dist/locales/en.js
DELETED
package/dist/locales/i18next.js
DELETED
package/dist/locales/zhCn.js
DELETED
package/dist/main.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import 'element-plus/dist/index.css';
|
|
2
|
-
import 'element-plus/theme-chalk/dark/css-vars.css';
|
|
3
|
-
import '@/assets/styles/init.scss';
|
|
4
|
-
import { createApp } from 'vue';
|
|
5
|
-
import { createPinia } from 'pinia';
|
|
6
|
-
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
|
|
7
|
-
import App from './App.vue';
|
|
8
|
-
const app = createApp(App);
|
|
9
|
-
// pinia 相关
|
|
10
|
-
const pinia = createPinia();
|
|
11
|
-
pinia.use(piniaPluginPersistedstate);
|
|
12
|
-
app.use(pinia);
|
|
13
|
-
app.mount('#app');
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import LingshuSmartEditor from '@/components/editor/index.vue';
|
|
2
|
-
// import casesJson from '@/assets/json/cases.json' // TODO 预设方案
|
|
3
|
-
/**
|
|
4
|
-
* 加载方案列表数据
|
|
5
|
-
* @param requestId 请求数据ID,即输入框输入的值(按需)
|
|
6
|
-
*/
|
|
7
|
-
const loadCases = async (requestId) => {
|
|
8
|
-
// 此处模拟异步请求,生产环境请按需替换为后端 API
|
|
9
|
-
const res = await fetch(`/json/cases.json?requestId=${requestId}`);
|
|
10
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
11
|
-
const data = await res.json();
|
|
12
|
-
return data.data;
|
|
13
|
-
};
|
|
14
|
-
// 保存方案列表按钮回调
|
|
15
|
-
const saveCases = (data) => {
|
|
16
|
-
console.log('保存方案列表数据', data);
|
|
17
|
-
};
|
|
18
|
-
// 预览按钮回调
|
|
19
|
-
const handlePreview = (currentCase) => {
|
|
20
|
-
console.log('跳转预览页面', currentCase);
|
|
21
|
-
window.open(`/preview/${currentCase?.uuid}`);
|
|
22
|
-
};
|
|
23
|
-
// 退出按钮回调
|
|
24
|
-
const handleExit = () => {
|
|
25
|
-
console.log('退出');
|
|
26
|
-
};
|
|
27
|
-
debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
|
|
28
|
-
const __VLS_ctx = {
|
|
29
|
-
...{},
|
|
30
|
-
...{},
|
|
31
|
-
};
|
|
32
|
-
let __VLS_components;
|
|
33
|
-
let __VLS_directives;
|
|
34
|
-
/** @type {[typeof LingshuSmartEditor, typeof LingshuSmartEditor, ]} */ ;
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
const __VLS_0 = __VLS_asFunctionalComponent(LingshuSmartEditor, new LingshuSmartEditor({
|
|
37
|
-
actions: ({
|
|
38
|
-
loadCases: __VLS_ctx.loadCases,
|
|
39
|
-
saveCases: __VLS_ctx.saveCases,
|
|
40
|
-
handlePreview: __VLS_ctx.handlePreview,
|
|
41
|
-
handleExit: __VLS_ctx.handleExit
|
|
42
|
-
}),
|
|
43
|
-
}));
|
|
44
|
-
const __VLS_1 = __VLS_0({
|
|
45
|
-
actions: ({
|
|
46
|
-
loadCases: __VLS_ctx.loadCases,
|
|
47
|
-
saveCases: __VLS_ctx.saveCases,
|
|
48
|
-
handlePreview: __VLS_ctx.handlePreview,
|
|
49
|
-
handleExit: __VLS_ctx.handleExit
|
|
50
|
-
}),
|
|
51
|
-
}, ...__VLS_functionalComponentArgsRest(__VLS_0));
|
|
52
|
-
var __VLS_4 = {};
|
|
53
|
-
// @ts-ignore
|
|
54
|
-
[loadCases, saveCases, handlePreview, handleExit,];
|
|
55
|
-
var __VLS_2;
|
|
56
|
-
const __VLS_export = (await import('vue')).defineComponent({});
|
|
57
|
-
export default {};
|