@jnrs/lingshu-smart 2.2.27 → 2.2.29
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/AGENTS.md +29 -16
- package/README.md +4 -40
- package/dist/components/index.js +299 -299
- package/dist/{index-tpebqVjC.js → index-xyCXB0RY.js} +1569 -1543
- package/dist/index.js +4 -3
- package/dist/ui/models/Rgv.d.ts +2 -2
- package/dist/utils/index.d.ts +8 -0
- package/package.json +2 -2
package/AGENTS.md
CHANGED
|
@@ -74,7 +74,7 @@ const handleExit = () => {
|
|
|
74
74
|
import { ref, computed, onMounted } from 'vue'
|
|
75
75
|
import type { ICase, ILayer, ILayerOperating, InteractiveUi } from '@/types'
|
|
76
76
|
import { EnumModel } from '@/types'
|
|
77
|
-
import { transRuntimeToPixel } from '@/utils'
|
|
77
|
+
import { transRuntimeToPixel, transPercentToPixel } from '@/utils'
|
|
78
78
|
import LingshuSmartPreview from '@/components/preview/index.vue'
|
|
79
79
|
|
|
80
80
|
const lingshuSmartPreviewRef = ref()
|
|
@@ -305,7 +305,7 @@ operating({
|
|
|
305
305
|
color: payload.status === 2 ? 'green' : '#424242',
|
|
306
306
|
blinking: payload.status === 2
|
|
307
307
|
},
|
|
308
|
-
x:
|
|
308
|
+
x: transPercentToPixel(payload.x, 2, 'width') // 沿轨道移动时需转换
|
|
309
309
|
})
|
|
310
310
|
```
|
|
311
311
|
|
|
@@ -320,7 +320,7 @@ operating({
|
|
|
320
320
|
color: payload.status === 2 ? 'green' : '#424242',
|
|
321
321
|
blinking: payload.status === 2
|
|
322
322
|
},
|
|
323
|
-
x:
|
|
323
|
+
x: transPercentToPixel(payload.x, 2, 'width'),
|
|
324
324
|
j1: payload.j1, // 一级关节角度(度)
|
|
325
325
|
currentFixture: payload.currentFixture // EnumResourceType.PALLET | TOOL
|
|
326
326
|
})
|
|
@@ -337,7 +337,7 @@ operating({
|
|
|
337
337
|
color: payload.status === 0 ? '#f30' : '#424242'
|
|
338
338
|
},
|
|
339
339
|
currentFixture: payload.currentFixture,
|
|
340
|
-
x:
|
|
340
|
+
x: transPercentToPixel(payload.x, 2, 'width'),
|
|
341
341
|
j1: payload.j1,
|
|
342
342
|
j2: payload.j2
|
|
343
343
|
})
|
|
@@ -392,10 +392,10 @@ operating({
|
|
|
392
392
|
id: payload.id,
|
|
393
393
|
rawData: payload,
|
|
394
394
|
light: { color: payload.lightColor, blinking: payload.blinking },
|
|
395
|
-
x:
|
|
395
|
+
x: transPercentToPixel(payload.x, 2, 'width'),
|
|
396
396
|
j1: payload.j1, // 旋转角度
|
|
397
|
-
forkXY: payload.forkXY, //
|
|
398
|
-
forkZ: payload.forkZ // 货叉升降比例 0
|
|
397
|
+
forkXY: payload.forkXY, // 货叉进出移动比例 [−1,1]
|
|
398
|
+
forkZ: payload.forkZ // 货叉升降比例 [0,1]
|
|
399
399
|
})
|
|
400
400
|
```
|
|
401
401
|
|
|
@@ -423,6 +423,18 @@ const pixelX = transRuntimeToPixel(payload.x, 1, 'width')
|
|
|
423
423
|
const pixelY = transRuntimeToPixel(payload.y, 1, 'height')
|
|
424
424
|
```
|
|
425
425
|
|
|
426
|
+
### 百分比转换为像素数值
|
|
427
|
+
|
|
428
|
+
后端推送的 `x` / `y` 通常为**百分比数值**(范围通常为[-1,1]),画布使用**像素坐标**。转换公式:
|
|
429
|
+
|
|
430
|
+
```typescript
|
|
431
|
+
import { transPercentToPixel } from '@jnrs/lingshu-smart'
|
|
432
|
+
|
|
433
|
+
// 宽方向:pixel = percentVal * scene.width
|
|
434
|
+
const pixelX = transPercentToPixel(payload.x, 2, 'width')
|
|
435
|
+
const pixelY = transPercentToPixel(payload.y, 1, 'height')
|
|
436
|
+
```
|
|
437
|
+
|
|
426
438
|
**前提:** 方案 `IScene` 中需配置 `runtime_width` / `runtime_height`。该函数读取 `useEditorStore().scene`,预览页需确保场景数据已加载。
|
|
427
439
|
|
|
428
440
|
### WebSocket 接入示例
|
|
@@ -559,14 +571,14 @@ type ILayerOperating =
|
|
|
559
571
|
|
|
560
572
|
#### IRGVOperating
|
|
561
573
|
|
|
562
|
-
| 属性 | 类型 | 说明
|
|
563
|
-
| ---------- | -------------------- |
|
|
564
|
-
| `light` | `ILightOperating` | 双灯同步更新
|
|
565
|
-
| `x` | `number` | 沿轨道位移(像素) |
|
|
566
|
-
| `j1` | `number` | 车体旋转角度(度)
|
|
567
|
-
| `forkXY` | `number` |
|
|
568
|
-
| `forkZ` | `number` | 货叉升降比例 0
|
|
569
|
-
| `resource` | `IResourceOperating` | 托盘/刀具工位槽
|
|
574
|
+
| 属性 | 类型 | 说明 |
|
|
575
|
+
| ---------- | -------------------- | ------------------------- |
|
|
576
|
+
| `light` | `ILightOperating` | 双灯同步更新 |
|
|
577
|
+
| `x` | `number` | 沿轨道位移(像素)[0,1] |
|
|
578
|
+
| `j1` | `number` | 车体旋转角度(度)[0,360] |
|
|
579
|
+
| `forkXY` | `number` | 货叉进出移动比例 [−1,1] |
|
|
580
|
+
| `forkZ` | `number` | 货叉升降比例 [0,1] |
|
|
581
|
+
| `resource` | `IResourceOperating` | 托盘/刀具工位槽 |
|
|
570
582
|
|
|
571
583
|
#### IRailOperating
|
|
572
584
|
|
|
@@ -666,6 +678,7 @@ type ILayerOperating =
|
|
|
666
678
|
| `transPercentAndPixel(val, size, precision?, getPercent?)` | 百分比 ↔ 像素 |
|
|
667
679
|
| `transFraction(val, size)` | 百分比转小数 |
|
|
668
680
|
| `transRuntimeToPixel(val, precision?, type?)` | 运行时坐标 → 像素(依赖 scene.runtime_width/height) |
|
|
681
|
+
| `transPercentToPixel(val, precision?, type?)` | 百分比数值 → 像素(依赖 scene.width/height) |
|
|
669
682
|
|
|
670
683
|
---
|
|
671
684
|
|
|
@@ -673,7 +686,7 @@ type ILayerOperating =
|
|
|
673
686
|
|
|
674
687
|
1. **编辑器 vs 预览:** 编辑模式配置 `EditorActions`;预览模式配置 `PreviewActions` + `onMessage` → `operating`
|
|
675
688
|
2. **ID 匹配:** `operating` 的 `id` 必须与方案图层 `rawData.id` 一致,否则静默失败(在前端层面该值即为编辑器组件中业务数据配置中必填项 id 的值,需根据后端预先提供的设备 id 在编辑器中进行配置)
|
|
676
|
-
3. **坐标系:** 轨道类设备的 `x` 通常需 `
|
|
689
|
+
3. **坐标系:** 轨道类设备的 `x` 通常需 `transPercentToPixel` 转换;`IRailOperating.x` 直接使用像素
|
|
677
690
|
4. **资源消息:** `Resource` 类型不对应独立图层,通过目标设备的 `resource` 字段操作工位槽
|
|
678
691
|
5. **引擎生命周期:** 组件卸载时自动 `destroyContainer`;手动集成需自行销毁
|
|
679
692
|
6. **类型安全:** 所有 API 均导出 TypeScript 类型,推荐 `import type { ILayerOperating, EnumModel } from '@jnrs/lingshu-smart'`
|
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
巨能前端 2D 数字孪生库,灵枢智造。
|
|
6
6
|
|
|
7
7
|
- 2D 数字孪生编辑器、运行看板
|
|
8
|
+
- ...
|
|
8
9
|
|
|
9
10
|
## 💻 技术栈
|
|
10
11
|
|
|
@@ -19,45 +20,8 @@ pnpm add @jnrs/lingshu-smart
|
|
|
19
20
|
## 🔍 使用示例
|
|
20
21
|
|
|
21
22
|
```typescript
|
|
22
|
-
import type {
|
|
23
|
-
import { LingshuSmartEditor } from '@jnrs/lingshu-smart/components'
|
|
23
|
+
import type { ILayerOperating } from '@jnrs/lingshu-smart'
|
|
24
|
+
import { LingshuSmartPreview, LingshuSmartEditor } from '@jnrs/lingshu-smart/components'
|
|
24
25
|
```
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
#### @jnrs/lingshu-smart/components 模块
|
|
29
|
-
|
|
30
|
-
Vue 组件
|
|
31
|
-
|
|
32
|
-
- LingshuSmartEditor 编辑器组件
|
|
33
|
-
|
|
34
|
-
| 属性名 | 描述 | 类型 | 默认值 |
|
|
35
|
-
| ------- | -------- | --------------- | ------ |
|
|
36
|
-
| actions | 事件处理 | `EditorActions` | {} |
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
interface EditorActions {
|
|
40
|
-
/**
|
|
41
|
-
* 加载案例列表
|
|
42
|
-
* @returns Promise<ICase[]>
|
|
43
|
-
*/
|
|
44
|
-
loadCases?: (id?: string) => Promise<ICase[]>
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 保存方案列表
|
|
48
|
-
*/
|
|
49
|
-
saveCases?: (cases?: ICase[]) => void
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* 跳转到预览页面
|
|
53
|
-
*/
|
|
54
|
-
handlePreview?: (currentCase?: ICase) => void
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* 退出当前页面
|
|
58
|
-
*/
|
|
59
|
-
handleExit?: () => void
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
详细文档请查看 `AGENTS.md`
|
|
27
|
+
详细文档请查看 [AGENTS.md](./AGENTS.md)
|