@jnrs/lingshu-smart 2.2.34 → 2.2.35
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 +4 -1
- package/README.md +1 -0
- package/dist/components/debug/DataLogPanel.vue.d.ts +44 -0
- package/dist/components/debug/DebugPanel.vue.d.ts +60 -1
- package/dist/components/debug/ScriptRunner/ConfigPanel.vue.d.ts +14 -11
- package/dist/components/debug/ScriptRunner/StepsPanel.vue.d.ts +8 -0
- package/dist/components/debug/ScriptRunner/script.d.ts +29 -1
- package/dist/components/debug/WsProxy/ConfigEditor.vue.d.ts +18 -0
- package/dist/components/debug/WsProxy/ConnPanel.vue.d.ts +24 -0
- package/dist/components/debug/WsProxy/WsProxyPage.vue.d.ts +14 -0
- package/dist/components/debug/WsProxy/broadcast.d.ts +31 -0
- package/dist/components/debug/WsProxy/index.vue.d.ts +39 -0
- package/dist/components/debug/WsProxy/proxy.d.ts +159 -0
- package/dist/components/editor/ControlBar/CaseTitleEdit.vue.d.ts +87 -87
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.js +14041 -11421
- package/dist/controller/AppController.d.ts +2 -0
- package/dist/lingshu-smart/wsProxyConfig.json +495 -0
- package/dist/locales/index.js +2 -2
- package/dist/playground/ViewPageDemo.vue.d.ts +58 -0
- package/dist/stores/useDebugStore.d.ts +375 -2
- package/dist/types/components/config.types.d.ts +1 -0
- package/dist/types/components/operating.types.d.ts +1 -0
- package/dist/types/models/operating.types.d.ts +14 -1
- package/dist/ui/abstract/ModelAbs.d.ts +10 -0
- package/dist/ui/components/StationSlot.d.ts +5 -1
- package/dist/ui/components/StationSlotGroup.d.ts +5 -0
- package/dist/ui/models/CleaningMachine.d.ts +2 -0
- package/dist/ui/models/DoubleJointRobot.d.ts +2 -0
- package/dist/ui/models/LoadingStation.d.ts +2 -0
- package/dist/ui/models/MachineTool.d.ts +2 -0
- package/dist/ui/models/MarkingMachine.d.ts +2 -0
- package/dist/ui/models/ResourceStore.d.ts +2 -0
- package/dist/ui/models/Rgv.d.ts +2 -0
- package/dist/ui/models/SingleJointRobot.d.ts +2 -0
- package/package.json +2 -2
- package/dist/components/debug/ScriptRunner/LogPanel.vue.d.ts +0 -19
- /package/dist/{json → lingshu-smart}/cases.json +0 -0
package/AGENTS.md
CHANGED
|
@@ -29,7 +29,7 @@ import type { ICase } from '@/types'
|
|
|
29
29
|
import LingshuSmartEditor from '@/components/editor/index.vue'
|
|
30
30
|
|
|
31
31
|
const loadCases = async (requestId?: string): Promise<ICase[]> => {
|
|
32
|
-
const res = await fetch(`/
|
|
32
|
+
const res = await fetch(`/lingshu-smart/cases.json?requestId=${requestId}`)
|
|
33
33
|
const data = await res.json()
|
|
34
34
|
return data.data
|
|
35
35
|
}
|
|
@@ -707,6 +707,9 @@ type ILayerOperating =
|
|
|
707
707
|
| `stores/useDebugStore.ts` | 全局调试配置 Pinia store,localStorage 持久化 |
|
|
708
708
|
| `composables/useDebugEasterEgg.ts` | 调试触发检测:500ms 内 10 次点击打开面板 |
|
|
709
709
|
| `components/debug/DebugPanel.vue` | 调试配置对话框 UI |
|
|
710
|
+
| `components/debug/ScriptRunner/` | Socket 脚本模拟器:脚本步骤编排、断点调试、消息结构配置(code/msg、payload 字段名、type)、日志查看 |
|
|
711
|
+
| `components/debug/WsProxy/` | WebSocket 代理器:声明式字段映射将后端 socket 结构桥接为 operating,支持连接/断开/重连、日志、配置导出/导入、场景像素换算(percentToPixel 百分比/ runtimeToPixel 运行时坐标)、standalone 独立标签页模式 / remote 远程接收模式(BroadcastChannel 跨标签页流转数据) |
|
|
712
|
+
| `components/debug/WsProxy/WsProxyPage.vue` | `WsProxy` 独立路由页面组件:以独立 URL/标签页运行代理器配置,将 operating/raw/状态广播给预览页驱动图形运转 |
|
|
710
713
|
| `controller/AppController.ts` | 提供 `toggleShadows` / `toggleAnimations` / `setFps` 方法 |
|
|
711
714
|
|
|
712
715
|
### 日志系统
|
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
| 设备模型 | 机床、机器人(单关节/双关节)、RGV、装载站、打标机、清洗机、轨道拖链、资源库等 |
|
|
14
14
|
| 设备运转 | 灯光、进度条、入口动画、工位槽资源增删、坐标/角度/货叉控制 |
|
|
15
15
|
| 坐标转换 | `transRuntimeToPixel` / `transPercentToPixel` — 物理坐标与像素坐标互转 |
|
|
16
|
+
| WebSocket 代理器 | `WsProxy` — 声明式字段映射将后端 socket 数据桥接为 operating 驱动设备动画;`WsProxyPage` 独立路由页面支持单独标签页配置并通过 BroadcastChannel 广播给预览页 |
|
|
16
17
|
|
|
17
18
|
## 💻 技术栈
|
|
18
19
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ILayerOperating } from '../../types';
|
|
2
|
+
export interface LogEntry {
|
|
3
|
+
datetime: string;
|
|
4
|
+
type: string;
|
|
5
|
+
traceId: string;
|
|
6
|
+
payload: any;
|
|
7
|
+
}
|
|
8
|
+
export type LogDirection = 'send' | 'receive';
|
|
9
|
+
export interface WsProxyLogEntry {
|
|
10
|
+
datetime: string;
|
|
11
|
+
direction: LogDirection;
|
|
12
|
+
data: any;
|
|
13
|
+
}
|
|
14
|
+
export type RunLogEntry = ILayerOperating;
|
|
15
|
+
type __VLS_Props = {
|
|
16
|
+
logs: any[];
|
|
17
|
+
maxLogCount: number;
|
|
18
|
+
snapshot: boolean;
|
|
19
|
+
/** 边框左上角区域名称(如 模拟消息日志 / 消息日志 / 运行日志) */
|
|
20
|
+
title?: string;
|
|
21
|
+
/** 数据列表头名称 */
|
|
22
|
+
dataLabel?: string;
|
|
23
|
+
/** 数据单元格渲染函数 */
|
|
24
|
+
textFn?: (row: any) => string;
|
|
25
|
+
/** 是否展示方向/类型列(WsProxy 消息日志专用) */
|
|
26
|
+
showDirectionType?: boolean;
|
|
27
|
+
};
|
|
28
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
29
|
+
copy: () => any;
|
|
30
|
+
clear: () => any;
|
|
31
|
+
"update:maxLogCount": (value: number) => any;
|
|
32
|
+
"toggle-snapshot": () => any;
|
|
33
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
34
|
+
onCopy?: (() => any) | undefined;
|
|
35
|
+
onClear?: (() => any) | undefined;
|
|
36
|
+
"onUpdate:maxLogCount"?: ((value: number) => any) | undefined;
|
|
37
|
+
"onToggle-snapshot"?: (() => any) | undefined;
|
|
38
|
+
}>, {
|
|
39
|
+
title: string;
|
|
40
|
+
dataLabel: string;
|
|
41
|
+
textFn: (row: any) => string;
|
|
42
|
+
showDirectionType: boolean;
|
|
43
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
44
|
+
export default _default;
|
|
@@ -1,2 +1,61 @@
|
|
|
1
|
-
declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
|
|
1
|
+
declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
|
|
2
|
+
wsProxyRef: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
|
|
3
|
+
autoApply?: boolean;
|
|
4
|
+
config?: import('./WsProxy/proxy').WsProxyConfig;
|
|
5
|
+
scene?: import('../..').IScene | null;
|
|
6
|
+
dictFn?: import('./WsProxy/proxy').DictFn;
|
|
7
|
+
standalone?: boolean;
|
|
8
|
+
remote?: boolean;
|
|
9
|
+
}> & Readonly<{
|
|
10
|
+
onOperating?: ((data: import('../..').ILayerOperating) => any) | undefined;
|
|
11
|
+
onRaw?: ((data: unknown) => any) | undefined;
|
|
12
|
+
"onStatus-change"?: ((connected: boolean) => any) | undefined;
|
|
13
|
+
}>, {
|
|
14
|
+
open: () => void;
|
|
15
|
+
feedMessage: (rawMessage: any) => void;
|
|
16
|
+
setConfig: (cfg: import('./WsProxy/proxy').WsProxyConfig) => void;
|
|
17
|
+
isConnected: import('vue').Ref<boolean, boolean>;
|
|
18
|
+
rules: import('vue').ComputedRef<import('./WsProxy/proxy').ProxyRule[]>;
|
|
19
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
20
|
+
operating: (data: import('../..').ILayerOperating) => any;
|
|
21
|
+
raw: (data: unknown) => any;
|
|
22
|
+
"status-change": (connected: boolean) => any;
|
|
23
|
+
}, import('vue').PublicProps, {
|
|
24
|
+
scene: import('../..').IScene | null;
|
|
25
|
+
config: import('./WsProxy/proxy').WsProxyConfig;
|
|
26
|
+
remote: boolean;
|
|
27
|
+
autoApply: boolean;
|
|
28
|
+
standalone: boolean;
|
|
29
|
+
}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
|
|
30
|
+
P: {};
|
|
31
|
+
B: {};
|
|
32
|
+
D: {};
|
|
33
|
+
C: {};
|
|
34
|
+
M: {};
|
|
35
|
+
Defaults: {};
|
|
36
|
+
}, Readonly<{
|
|
37
|
+
autoApply?: boolean;
|
|
38
|
+
config?: import('./WsProxy/proxy').WsProxyConfig;
|
|
39
|
+
scene?: import('../..').IScene | null;
|
|
40
|
+
dictFn?: import('./WsProxy/proxy').DictFn;
|
|
41
|
+
standalone?: boolean;
|
|
42
|
+
remote?: boolean;
|
|
43
|
+
}> & Readonly<{
|
|
44
|
+
onOperating?: ((data: import('../..').ILayerOperating) => any) | undefined;
|
|
45
|
+
onRaw?: ((data: unknown) => any) | undefined;
|
|
46
|
+
"onStatus-change"?: ((connected: boolean) => any) | undefined;
|
|
47
|
+
}>, {
|
|
48
|
+
open: () => void;
|
|
49
|
+
feedMessage: (rawMessage: any) => void;
|
|
50
|
+
setConfig: (cfg: import('./WsProxy/proxy').WsProxyConfig) => void;
|
|
51
|
+
isConnected: import('vue').Ref<boolean, boolean>;
|
|
52
|
+
rules: import('vue').ComputedRef<import('./WsProxy/proxy').ProxyRule[]>;
|
|
53
|
+
}, {}, {}, {}, {
|
|
54
|
+
scene: import('../..').IScene | null;
|
|
55
|
+
config: import('./WsProxy/proxy').WsProxyConfig;
|
|
56
|
+
remote: boolean;
|
|
57
|
+
autoApply: boolean;
|
|
58
|
+
standalone: boolean;
|
|
59
|
+
}> | null;
|
|
60
|
+
}, any>;
|
|
2
61
|
export default _default;
|
|
@@ -12,24 +12,27 @@ type __VLS_Props = {
|
|
|
12
12
|
deviceOptions: DeviceOption[];
|
|
13
13
|
resourceDeviceOptions: DeviceOption[];
|
|
14
14
|
statusDisplayColor: string;
|
|
15
|
-
selectedDeviceValue:
|
|
16
|
-
addDeviceValue:
|
|
17
|
-
removeDeviceValue:
|
|
15
|
+
selectedDeviceValue: DeviceOption | null;
|
|
16
|
+
addDeviceValue: DeviceOption | null;
|
|
17
|
+
removeDeviceValue: DeviceOption | null;
|
|
18
|
+
customData: string;
|
|
18
19
|
};
|
|
19
20
|
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
20
|
-
copy: (uid: string) => any;
|
|
21
21
|
delete: (uid: string) => any;
|
|
22
|
-
|
|
23
|
-
"update:
|
|
24
|
-
"update:
|
|
22
|
+
copy: (uid: string) => any;
|
|
23
|
+
"update:selectedDeviceValue": (value: DeviceOption | null) => any;
|
|
24
|
+
"update:addDeviceValue": (value: "" | DeviceOption) => any;
|
|
25
|
+
"update:removeDeviceValue": (value: "" | DeviceOption) => any;
|
|
26
|
+
"update:customData": (value: string) => any;
|
|
25
27
|
"move-up": (uid: string) => any;
|
|
26
28
|
"move-down": (uid: string) => any;
|
|
27
29
|
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
28
|
-
onCopy?: ((uid: string) => any) | undefined;
|
|
29
30
|
onDelete?: ((uid: string) => any) | undefined;
|
|
30
|
-
|
|
31
|
-
"onUpdate:
|
|
32
|
-
"onUpdate:
|
|
31
|
+
onCopy?: ((uid: string) => any) | undefined;
|
|
32
|
+
"onUpdate:selectedDeviceValue"?: ((value: DeviceOption | null) => any) | undefined;
|
|
33
|
+
"onUpdate:addDeviceValue"?: ((value: "" | DeviceOption) => any) | undefined;
|
|
34
|
+
"onUpdate:removeDeviceValue"?: ((value: "" | DeviceOption) => any) | undefined;
|
|
35
|
+
"onUpdate:customData"?: ((value: string) => any) | undefined;
|
|
33
36
|
"onMove-up"?: ((uid: string) => any) | undefined;
|
|
34
37
|
"onMove-down"?: ((uid: string) => any) | undefined;
|
|
35
38
|
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { ScriptStep, ScriptTemplate } from './script';
|
|
2
|
+
/** 设备/资源下拉选项 */
|
|
3
|
+
interface DeviceOption {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
className: string;
|
|
7
|
+
nameplate: string;
|
|
8
|
+
}
|
|
2
9
|
type __VLS_Props = {
|
|
3
10
|
scriptSteps: ScriptStep[];
|
|
4
11
|
selectedStepUid: string;
|
|
@@ -13,6 +20,7 @@ type __VLS_Props = {
|
|
|
13
20
|
allChecked: boolean;
|
|
14
21
|
isIndeterminate: boolean;
|
|
15
22
|
scriptTemplates: ScriptTemplate[];
|
|
23
|
+
deviceOptions: DeviceOption[];
|
|
16
24
|
};
|
|
17
25
|
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
18
26
|
add: () => any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @File : script.ts
|
|
3
|
-
* @Desc. :
|
|
3
|
+
* @Desc. : 脚本模拟器的设备字段配置与预设模板
|
|
4
4
|
*/
|
|
5
5
|
/** 字段配置 */
|
|
6
6
|
export interface ScriptFieldConfig {
|
|
@@ -24,6 +24,18 @@ export interface ScriptStep {
|
|
|
24
24
|
delay: number;
|
|
25
25
|
enabled: boolean;
|
|
26
26
|
params: Record<string, any>;
|
|
27
|
+
/** 返回码(0 操作成功 / 400 客户端参数错误 / 500 服务端处理异常) */
|
|
28
|
+
code: number;
|
|
29
|
+
/** 返回消息说明(可选 code 自动带入后可修改) */
|
|
30
|
+
msg: string;
|
|
31
|
+
/** 消息体字段名:'data' 或 'payload' */
|
|
32
|
+
payloadKey: 'data' | 'payload';
|
|
33
|
+
/** 顶层 type 值(可自由配置,默认 'update') */
|
|
34
|
+
msgType: string;
|
|
35
|
+
/** 自定义业务数据 JSON 文本(设备/资源选择「自定义」时启用,作为业务数据) */
|
|
36
|
+
customData?: string;
|
|
37
|
+
/** type 字段覆盖值:设置后业务数据中的 type 使用此值而非 deviceType */
|
|
38
|
+
typeOverride?: string;
|
|
27
39
|
}
|
|
28
40
|
/** 脚本模板 */
|
|
29
41
|
export interface ScriptTemplate {
|
|
@@ -36,6 +48,8 @@ export declare const deviceTypeOptions: {
|
|
|
36
48
|
label: string;
|
|
37
49
|
value: string;
|
|
38
50
|
}[];
|
|
51
|
+
/** 设备/资源下拉「自定义」选项的标识值(选中后编辑自定义业务数据 JSON) */
|
|
52
|
+
export declare const CUSTOM_DEVICE_TYPE = "__custom__";
|
|
39
53
|
/** 资源类型选项 */
|
|
40
54
|
export declare const resourceTypeOptions: {
|
|
41
55
|
label: string;
|
|
@@ -50,6 +64,20 @@ export interface CommonStatusOption {
|
|
|
50
64
|
export declare const commonDict: CommonStatusOption[];
|
|
51
65
|
/** 资源状态字典:资源增删专用,状态值/文本/颜色三要素 */
|
|
52
66
|
export declare const resourceDict: CommonStatusOption[];
|
|
67
|
+
/** 返回码字典:code / 说明,供「返回码」下拉与 msg 自动带入使用 */
|
|
68
|
+
export interface CodeOption {
|
|
69
|
+
label: string;
|
|
70
|
+
value: number;
|
|
71
|
+
}
|
|
72
|
+
export declare const codeDict: CodeOption[];
|
|
73
|
+
/** 默认消息体字段名 */
|
|
74
|
+
export declare const defaultPayloadKey: 'data' | 'payload';
|
|
75
|
+
/** 默认顶层 type 值 */
|
|
76
|
+
export declare const defaultMsgType = "update";
|
|
77
|
+
/** 默认返回码 */
|
|
78
|
+
export declare const defaultCode = 0;
|
|
79
|
+
/** 默认返回说明 */
|
|
80
|
+
export declare const defaultMsg = "\u64CD\u4F5C\u6210\u529F";
|
|
53
81
|
/** 可作为资源容器的设备类型 */
|
|
54
82
|
export declare const containerDeviceOptions: {
|
|
55
83
|
label: string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { WsProxyConfig } from './proxy';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
config: WsProxyConfig;
|
|
4
|
+
/** 配置来源:localFile 本地文件 / store 持久化配置(含用户手动修改场景) */
|
|
5
|
+
configSource: 'localFile' | 'store';
|
|
6
|
+
/** 用户是否已手动修改配置(configSource 为 store 时区分「本地文件异常」与「已手动修改配置」) */
|
|
7
|
+
manualModified?: boolean;
|
|
8
|
+
/** 是否已配置 dictFn(用于「字典 Label / 字典 Color」选项右侧 tag 显示) */
|
|
9
|
+
hasDictFn?: boolean;
|
|
10
|
+
};
|
|
11
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
12
|
+
reset: (value: WsProxyConfig) => any;
|
|
13
|
+
"update:config": (value: WsProxyConfig) => any;
|
|
14
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
15
|
+
onReset?: ((value: WsProxyConfig) => any) | undefined;
|
|
16
|
+
"onUpdate:config"?: ((value: WsProxyConfig) => any) | undefined;
|
|
17
|
+
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
url: string;
|
|
3
|
+
isConnected: boolean;
|
|
4
|
+
isConnecting: boolean;
|
|
5
|
+
stateInfo: string;
|
|
6
|
+
/** 心跳检测间隔(秒):0=关闭 */
|
|
7
|
+
heartbeatInterval: number;
|
|
8
|
+
};
|
|
9
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
10
|
+
"update:url": (value: string) => any;
|
|
11
|
+
"update:heartbeatInterval": (value: number) => any;
|
|
12
|
+
connect: () => any;
|
|
13
|
+
disconnect: () => any;
|
|
14
|
+
reconnect: () => any;
|
|
15
|
+
send: (data: string) => any;
|
|
16
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
17
|
+
"onUpdate:url"?: ((value: string) => any) | undefined;
|
|
18
|
+
"onUpdate:heartbeatInterval"?: ((value: number) => any) | undefined;
|
|
19
|
+
onConnect?: (() => any) | undefined;
|
|
20
|
+
onDisconnect?: (() => any) | undefined;
|
|
21
|
+
onReconnect?: (() => any) | undefined;
|
|
22
|
+
onSend?: ((data: string) => any) | undefined;
|
|
23
|
+
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IScene } from '../../../types';
|
|
2
|
+
import { DictFn } from './proxy';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
/** 场景信息:用于字段映射中像素换算(如 currentCase.scene) */
|
|
5
|
+
scene?: IScene | null;
|
|
6
|
+
/** 字典转换函数:用于「字典 Label / 字典 Color」特殊处理
|
|
7
|
+
* 入参 (name, value, type),返回 string 赋给画布字段 */
|
|
8
|
+
dictFn?: DictFn;
|
|
9
|
+
};
|
|
10
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
11
|
+
scene: IScene | null;
|
|
12
|
+
dictFn: DictFn;
|
|
13
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @File : broadcast.ts
|
|
3
|
+
* @Desc. : WsProxy 跨标签页数据流转(BroadcastChannel)
|
|
4
|
+
* 独立标签页运行代理器(standalone)时,将转换后的 operating / raw / 状态
|
|
5
|
+
* 通过 BroadcastChannel 广播给同源的其他标签页(如数字孪生预览页),
|
|
6
|
+
* 实现「独立 tab 配置代理 → 预览页驱动图形运转」的数据流转。
|
|
7
|
+
*/
|
|
8
|
+
/** 广播频道名:同源多个标签页共享 */
|
|
9
|
+
export declare const PROXY_CHANNEL = "jnrs-wsproxy-v1";
|
|
10
|
+
/** 广播消息类型 */
|
|
11
|
+
export type ProxyBroadcastMsg = {
|
|
12
|
+
type: 'operating';
|
|
13
|
+
data: unknown;
|
|
14
|
+
} | {
|
|
15
|
+
type: 'raw';
|
|
16
|
+
data: unknown;
|
|
17
|
+
} | {
|
|
18
|
+
type: 'status';
|
|
19
|
+
connected: boolean;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 创建广播通道
|
|
23
|
+
* @returns BroadcastChannel 实例(浏览器不支持时返回 null)
|
|
24
|
+
*/
|
|
25
|
+
export declare function createProxyChannel(): BroadcastChannel | null;
|
|
26
|
+
/** 向广播通道发送消息(standalone 代理器广播用) */
|
|
27
|
+
export declare function broadcastProxy(channel: BroadcastChannel | null, msg: ProxyBroadcastMsg): void;
|
|
28
|
+
/** 订阅广播通道消息(预览页接收用),返回取消订阅函数 */
|
|
29
|
+
export declare function subscribeProxy(channel: BroadcastChannel | null, handler: (msg: ProxyBroadcastMsg) => void): () => void;
|
|
30
|
+
/** 关闭广播通道 */
|
|
31
|
+
export declare function closeProxyChannel(channel: BroadcastChannel | null): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ILayerOperating, IScene } from '../../../types';
|
|
2
|
+
import { WsProxyConfig, ProxyRule, DictFn } from './proxy';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
/** 是否自动应用注入的消息(父组件调用 expose 的 feedMessage 时) */
|
|
5
|
+
autoApply?: boolean;
|
|
6
|
+
/** 初始配置 */
|
|
7
|
+
config?: WsProxyConfig;
|
|
8
|
+
/** 场景信息:用于字段映射中 percentToPixel 换算(如 currentCase.scene) */
|
|
9
|
+
scene?: IScene | null;
|
|
10
|
+
/** 字典转换函数:用于「字典 Label / 字典 Color」特殊处理
|
|
11
|
+
* 入参 (name: string, value?: string|number, type: 'label'|'color'),返回 string 赋给画布字段 */
|
|
12
|
+
dictFn?: DictFn;
|
|
13
|
+
/** 独立标签页模式:全屏布局,自动打开,并将 operating/raw/状态 通过 BroadcastChannel 广播 */
|
|
14
|
+
standalone?: boolean;
|
|
15
|
+
/** 远程接收模式:监听 BroadcastChannel,将独立代理器广播的 operating/raw/状态 透传给父组件 */
|
|
16
|
+
remote?: boolean;
|
|
17
|
+
};
|
|
18
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {
|
|
19
|
+
open: () => void;
|
|
20
|
+
feedMessage: (rawMessage: any) => void;
|
|
21
|
+
setConfig: (cfg: WsProxyConfig) => void;
|
|
22
|
+
isConnected: import('vue').Ref<boolean, boolean>;
|
|
23
|
+
rules: import('vue').ComputedRef<ProxyRule[]>;
|
|
24
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
25
|
+
operating: (data: ILayerOperating) => any;
|
|
26
|
+
raw: (data: unknown) => any;
|
|
27
|
+
"status-change": (connected: boolean) => any;
|
|
28
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
29
|
+
onOperating?: ((data: ILayerOperating) => any) | undefined;
|
|
30
|
+
onRaw?: ((data: unknown) => any) | undefined;
|
|
31
|
+
"onStatus-change"?: ((connected: boolean) => any) | undefined;
|
|
32
|
+
}>, {
|
|
33
|
+
scene: IScene | null;
|
|
34
|
+
config: WsProxyConfig;
|
|
35
|
+
remote: boolean;
|
|
36
|
+
autoApply: boolean;
|
|
37
|
+
standalone: boolean;
|
|
38
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
39
|
+
export default _default;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { ILayerOperating, IScene } from '../../../types';
|
|
2
|
+
/** 条件判断项:当源值满足 operator + operand 条件时,将 value 赋给画布字段 */
|
|
3
|
+
export interface ConditionRule {
|
|
4
|
+
/** 比较运算符 */
|
|
5
|
+
operator: 'eq' | 'ne' | 'gt' | 'lt' | 'gte' | 'lte' | 'includes' | 'in';
|
|
6
|
+
/** 比较目标值('in' 运算符时为逗号分隔的列表,如 '1,2,3') */
|
|
7
|
+
operand: string;
|
|
8
|
+
/** 条件为 true 时赋给画布字段的值 */
|
|
9
|
+
value: string | number | boolean;
|
|
10
|
+
}
|
|
11
|
+
/** 字段映射项:将一个 operating 目标字段映射到 payload 源字段/常量/值映射 */
|
|
12
|
+
export interface FieldMapper {
|
|
13
|
+
/** operating 目标路径(支持点号嵌套,如 light.color) */
|
|
14
|
+
target: string;
|
|
15
|
+
/** payload 源字段路径(支持点号嵌套,如 displayColor) */
|
|
16
|
+
source?: string;
|
|
17
|
+
/** 常量值(与 source 互斥,优先级最高) */
|
|
18
|
+
constant?: boolean | number | string;
|
|
19
|
+
/** 值映射:把源字段的取值映射为指定值(键为源值字符串,如 { '1': true }) */
|
|
20
|
+
valueMap?: Record<string, boolean | number | string>;
|
|
21
|
+
/** 源字段为空或未命中 valueMap 时的兜底值 */
|
|
22
|
+
defaultValue?: boolean | number | string;
|
|
23
|
+
/** 是否启用该映射(默认 true) */
|
|
24
|
+
enabled?: boolean;
|
|
25
|
+
/** 特殊处理:'percentToPixel' 百分比转像素 / 'runtimeToPixel' 运行时坐标转像素 / 'dictLabel' 字典Label / 'dictColor' 字典Color / 'condition' 条件判断;为空表示不处理 */
|
|
26
|
+
transform?: 'percentToPixel' | 'runtimeToPixel' | 'dictLabel' | 'dictColor' | 'condition';
|
|
27
|
+
/** 换算维度(transform 为 percentToPixel / runtimeToPixel 时必填):'width' 横向 / 'height' 纵向 */
|
|
28
|
+
transformType?: 'width' | 'height';
|
|
29
|
+
/** 换算精度(transform 为 percentToPixel 时生效,默认 2) */
|
|
30
|
+
transformPrecision?: number;
|
|
31
|
+
/** 字典名称(transform 为 dictLabel / dictColor 时生效,传给 dictFn 的 name 入参) */
|
|
32
|
+
dictName?: string;
|
|
33
|
+
/** 条件判断列表(transform 为 'condition' 时生效,按顺序匹配首个为 true 的条件,赋其 value 给画布字段;无匹配时保持源值) */
|
|
34
|
+
conditions?: ConditionRule[];
|
|
35
|
+
}
|
|
36
|
+
/** 字典转换函数:将「源业务数据」字段值按字典名称转换为「画布字段」值
|
|
37
|
+
* @param name 特殊处理配置下的字典名称(dictName)
|
|
38
|
+
* @param value 源业务数据字段所对应的值
|
|
39
|
+
* @param type 'label' 字典Label / 'color' 字典Color
|
|
40
|
+
* @returns 转换后的字符串值,赋值给画布字段 */
|
|
41
|
+
export type DictFn = (name: string, value: string | number | undefined, type: 'label' | 'color') => string;
|
|
42
|
+
/** 资源操作字段配置:定义 payload 中各字段的来源路径 */
|
|
43
|
+
export interface ResourceFieldConfig {
|
|
44
|
+
/** 资源 className 的源字段路径(如 addType / removeType) */
|
|
45
|
+
className: string;
|
|
46
|
+
/** 资源 ID 的源字段路径(如 addId / removeId) */
|
|
47
|
+
id: string;
|
|
48
|
+
/** 资源类型的源字段路径(如 resourceType) */
|
|
49
|
+
resourceType: string;
|
|
50
|
+
/** 资源 ID 的源字段路径(用于全局查找匹配,如 resourceId) */
|
|
51
|
+
resourceId?: string;
|
|
52
|
+
/** 工位索引的源字段路径(如 addSiteNumber / removeSiteNumber) */
|
|
53
|
+
index: string;
|
|
54
|
+
/** 资源名称的源字段路径(仅 add 需要,如 name) */
|
|
55
|
+
name?: string;
|
|
56
|
+
/** 资源颜色的源字段路径(仅 add 需要,如 displayColor) */
|
|
57
|
+
color?: string;
|
|
58
|
+
}
|
|
59
|
+
/** 资源增删字段映射:分别配置 add / remove 两组字段来源 */
|
|
60
|
+
export interface ResourceFieldMap {
|
|
61
|
+
/** 新增资源字段映射(不需要新增时可不配置) */
|
|
62
|
+
add?: ResourceFieldConfig;
|
|
63
|
+
/** 移除资源字段映射(不需要移除时可不配置) */
|
|
64
|
+
remove?: ResourceFieldConfig;
|
|
65
|
+
}
|
|
66
|
+
/** 全局操作字段配置(operate: 'global' 时生效) */
|
|
67
|
+
export interface GlobalFieldConfig {
|
|
68
|
+
/** resourceIds 的源字段路径(从源消息中提取资源 ID 数组;为空时使用 payloadKey,如 'data') */
|
|
69
|
+
resourceIds: string;
|
|
70
|
+
}
|
|
71
|
+
/** 单条类型代理规则 */
|
|
72
|
+
export interface ProxyRule {
|
|
73
|
+
/** 源 type:后端消息头的 type 原始值(如 '7'),配置后优先用于匹配,匹配该规则的 operating */
|
|
74
|
+
sourceType?: string;
|
|
75
|
+
/** 前端 operating 的 className(EnumModel 值),同时作为类型列表的唯一标识 */
|
|
76
|
+
className: string;
|
|
77
|
+
/** 设备名称(画布模型类对应的 equipmentName,用于类型列表上行展示) */
|
|
78
|
+
equipmentName?: string;
|
|
79
|
+
/** 是否启用该规则 */
|
|
80
|
+
enabled: boolean;
|
|
81
|
+
/** 操作模式:single 单条 operating;resource 资源增删(生成 add/remove 两条);global 全局操作(如批量移除) */
|
|
82
|
+
operate: 'single' | 'resource' | 'global';
|
|
83
|
+
/** 字段映射列表(operate: 'single' 时生效) */
|
|
84
|
+
mappings: FieldMapper[];
|
|
85
|
+
/** 资源增删字段映射(operate: 'resource' 时生效,未配置时使用内置默认字段名) */
|
|
86
|
+
resourceFields?: ResourceFieldMap;
|
|
87
|
+
/** 全局操作字段映射(operate: 'global' 时生效) */
|
|
88
|
+
globalFields?: GlobalFieldConfig;
|
|
89
|
+
}
|
|
90
|
+
/** WsProxy 代理配置(可导出为 JSON) */
|
|
91
|
+
export interface WsProxyConfig {
|
|
92
|
+
/** 配置文件相对路径(不含 .json,支持嵌套如 lingshu-smart/wsProxyConfig) */
|
|
93
|
+
name: string;
|
|
94
|
+
/** 配置版本 */
|
|
95
|
+
version: number;
|
|
96
|
+
/** 默认 WebSocket 地址(可选) */
|
|
97
|
+
wsUrl?: string;
|
|
98
|
+
/** 业务数据字段名:源消息下该字段的数据作为画布运行 payload(默认 data) */
|
|
99
|
+
payloadKey?: string;
|
|
100
|
+
/** 源类型字段名:从源消息中提取设备类型的字段路径(默认 type,可设为 data.type 等) */
|
|
101
|
+
sourceTypeField?: string;
|
|
102
|
+
/** 心跳检测间隔(秒):0=关闭;>0=开启,定期发送心跳消息检测连接活性 */
|
|
103
|
+
heartbeatInterval?: number;
|
|
104
|
+
/** 各消息类型的代理规则 */
|
|
105
|
+
rules: ProxyRule[];
|
|
106
|
+
}
|
|
107
|
+
/** 按点号路径从对象取值 */
|
|
108
|
+
export declare function getPath(obj: unknown, path: string): unknown;
|
|
109
|
+
/** 按点号路径在对象上设值(自动创建中间对象) */
|
|
110
|
+
export declare function setPath(obj: Record<string, unknown>, path: string, value: unknown): void;
|
|
111
|
+
/** 解析单个字段映射:常量 > 值映射 > 源字段 > 默认值
|
|
112
|
+
* @param dictFn 字典转换函数(可选,未传入时按默认规则:label 原样返回 value,color 返回 '#fff') */
|
|
113
|
+
export declare function resolveMapper(payload: Record<string, unknown>, mapper: FieldMapper, scene?: IScene | null, dictFn?: DictFn): unknown;
|
|
114
|
+
/** 根据单条规则构建 operating 对象(operate: 'single') */
|
|
115
|
+
export declare function buildOperating(payload: Record<string, unknown>, rule: ProxyRule, scene?: IScene | null, dictFn?: DictFn): ILayerOperating | null;
|
|
116
|
+
/** 根据 Resource 规则构建资源增删 operating 列表(operate: 'resource')
|
|
117
|
+
* 字段来源由 rule.resourceFields 配置,未配置时使用内置默认字段名 */
|
|
118
|
+
export declare function buildResourceOperating(payload: Record<string, unknown>, rule: ProxyRule): ILayerOperating[];
|
|
119
|
+
/** 根据全局操作规则构建 operating(operate: 'global')
|
|
120
|
+
* resourceIds 从源消息中按 globalFields.resourceIds 路径提取,为空时使用 payloadKey */
|
|
121
|
+
export declare function buildGlobalOperating(msg: Record<string, unknown>, rule: ProxyRule, payloadKey: string): ILayerOperating[];
|
|
122
|
+
/**
|
|
123
|
+
* 将原始 WebSocket 消息转换为 operating 列表
|
|
124
|
+
* 标准化数据(payload 为对象)走 @operating;非标准化数据(payload 为数组)返回空数组,由 @raw 事件透出供父组件处理。
|
|
125
|
+
* @param rawMessage 原始消息
|
|
126
|
+
* @param rules 规则列表
|
|
127
|
+
* @param scene 场景信息(用于 percentToPixel 换算)
|
|
128
|
+
* @param payloadKey 业务数据字段名:源消息下该字段的数据作为画布运行 payload(默认 data,回退到 payload)
|
|
129
|
+
* @param sourceTypeField 源类型字段名:从源消息中提取设备类型的字段路径(默认 type)
|
|
130
|
+
* @param dictFn 字典转换函数(可选,用于 dictLabel / dictColor 特殊处理)
|
|
131
|
+
* @returns operating 列表(可能为空数组;非标准数组数据返回空数组由 @raw 处理)
|
|
132
|
+
*/
|
|
133
|
+
export declare function applyProxy(rawMessage: unknown, rules: ProxyRule[], scene?: IScene | null, payloadKey?: string, sourceTypeField?: string, dictFn?: DictFn): ILayerOperating[];
|
|
134
|
+
/** 默认代理配置 */
|
|
135
|
+
export declare function createDefaultConfig(): WsProxyConfig;
|
|
136
|
+
/** 校验导入的配置结构是否合法 */
|
|
137
|
+
export declare function validateConfig(raw: unknown): WsProxyConfig | null;
|
|
138
|
+
/** 将配置序列化为 JSON 字符串 */
|
|
139
|
+
export declare function serializeConfig(config: WsProxyConfig): string;
|
|
140
|
+
/** 触发浏览器下载 JSON 配置文件(文件名:wsProxyConfig_ + 年月日时分秒) */
|
|
141
|
+
export declare function downloadConfig(config: WsProxyConfig): void;
|
|
142
|
+
/** 生成导出文件名:wsProxyConfig_yyyy_MM_dd_HH_mm_ss */
|
|
143
|
+
export declare function timestampName(): string;
|
|
144
|
+
/** 本地文件配置加载结果 */
|
|
145
|
+
export type LocalFileConfigResult = {
|
|
146
|
+
status: 'ok';
|
|
147
|
+
config: WsProxyConfig;
|
|
148
|
+
} | {
|
|
149
|
+
status: 'missing';
|
|
150
|
+
reason: string;
|
|
151
|
+
} | {
|
|
152
|
+
status: 'invalid';
|
|
153
|
+
reason: string;
|
|
154
|
+
} | {
|
|
155
|
+
status: 'unknown';
|
|
156
|
+
reason: string;
|
|
157
|
+
};
|
|
158
|
+
/** 从业务工程 public 目录读取配置文件(name 为相对路径,如 lingshu-smart/wsProxyConfig) */
|
|
159
|
+
export declare function loadLocalFileConfig(name: string): Promise<LocalFileConfigResult>;
|