model-action 2.1.0 → 2.2.1
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/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/Action.d.ts +16 -4
- package/dist/modules/Action.d.ts.map +1 -1
- package/dist/modules/Action.js +82 -7
- package/dist/modules/Action.js.map +1 -1
- package/dist/modules/Init.d.ts.map +1 -1
- package/dist/modules/Init.js +9 -20
- package/dist/modules/Init.js.map +1 -1
- package/dist/modules/SceneAsset.d.ts +115 -0
- package/dist/modules/SceneAsset.d.ts.map +1 -0
- package/dist/modules/SceneAsset.js +97 -0
- package/dist/modules/SceneAsset.js.map +1 -0
- package/dist/modules/SingleMesh.d.ts +54 -0
- package/dist/modules/SingleMesh.d.ts.map +1 -0
- package/dist/modules/SingleMesh.js +33 -0
- package/dist/modules/SingleMesh.js.map +1 -0
- package/dist/modules/Window.d.ts +63 -10
- package/dist/modules/Window.d.ts.map +1 -1
- package/dist/modules/Window.js +30 -27
- package/dist/modules/Window.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +33 -0
- package/src/modules/Action.ts +99 -11
- package/src/modules/Init.ts +8 -22
- package/src/modules/SceneAsset.ts +242 -0
- package/src/modules/SingleMesh.ts +89 -0
- package/src/modules/Window.ts +128 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 模型单体化:将指定模型转为可操作实例,支持 init / add / remove。
|
|
3
|
+
* POI 替代方案请走 POI 接口;本接口生成的是场景内模型实例。
|
|
4
|
+
*/
|
|
5
|
+
import { Action, SendParam } from "./Action";
|
|
6
|
+
|
|
7
|
+
export type SingleMeshOp = "init" | "add" | "remove";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 接口使用场景区分:Normal 通用;JF 等由项目约定。
|
|
11
|
+
* 无特殊场景可不传,三维按通用处理。
|
|
12
|
+
*/
|
|
13
|
+
export type SingleMeshSceneType = "Normal" | "JF" | string;
|
|
14
|
+
|
|
15
|
+
/** 设备模型类型,如服务器、交换机,项目约定 */
|
|
16
|
+
export type SingleMeshDeviceModelType = "Service" | "Switch" | string;
|
|
17
|
+
|
|
18
|
+
/** 设备类别:机柜 | 机柜内设备 等 */
|
|
19
|
+
export type SingleMeshDeviceCategory = "Cabinet" | "CDevice" | string;
|
|
20
|
+
|
|
21
|
+
export interface SingleMeshDevice {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
type: SingleMeshDeviceModelType;
|
|
25
|
+
/** 非必须,内置可补全 */
|
|
26
|
+
category?: SingleMeshDeviceCategory;
|
|
27
|
+
/** 如机柜内设备填所属机柜 id */
|
|
28
|
+
parentId?: string;
|
|
29
|
+
parentCategory?: SingleMeshDeviceCategory;
|
|
30
|
+
/** 在父设备上的槽口,机柜内设备按项目必传 */
|
|
31
|
+
socketOnParent?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface SingleMeshScene {
|
|
35
|
+
/** 场景/机房编码,项目约定;不传则当前场景 */
|
|
36
|
+
sceneCode?: string;
|
|
37
|
+
sceneName?: string;
|
|
38
|
+
devices: SingleMeshDevice[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type SingleMeshPayload =
|
|
42
|
+
| {
|
|
43
|
+
action: "add";
|
|
44
|
+
scenes: SingleMeshScene[];
|
|
45
|
+
sceneType?: SingleMeshSceneType;
|
|
46
|
+
}
|
|
47
|
+
| {
|
|
48
|
+
action: "init" | "remove";
|
|
49
|
+
scenes: SingleMeshScene[];
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type SingleMeshParamType = SendParam & {
|
|
53
|
+
cmd: "singleMesh";
|
|
54
|
+
data: SingleMeshPayload;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export class SingleMeshAction extends Action {
|
|
58
|
+
private static emit(data: SingleMeshPayload, log: string) {
|
|
59
|
+
return this.sendParam(
|
|
60
|
+
{ cmd: "singleMesh", data } as SingleMeshParamType,
|
|
61
|
+
log
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** 初始化场景内单体化数据 */
|
|
66
|
+
static init(scenes: SingleMeshScene[]) {
|
|
67
|
+
return this.emit({ action: "init", scenes }, "单体化 init");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 增加单体化设备/模型
|
|
72
|
+
* @param sceneType 非必须;机房等特殊场景传如 JF,默认不传为通用 Normal
|
|
73
|
+
*/
|
|
74
|
+
static add(scenes: SingleMeshScene[], sceneType?: SingleMeshSceneType) {
|
|
75
|
+
const data: Extract<SingleMeshPayload, { action: "add" }> = {
|
|
76
|
+
action: "add",
|
|
77
|
+
scenes
|
|
78
|
+
};
|
|
79
|
+
if (sceneType != null && sceneType !== "") {
|
|
80
|
+
data.sceneType = sceneType;
|
|
81
|
+
}
|
|
82
|
+
return this.emit(data, `单体化 add${sceneType ? ` (${sceneType})` : ""}`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** 移除单体化实例 */
|
|
86
|
+
static remove(scenes: SingleMeshScene[]) {
|
|
87
|
+
return this.emit({ action: "remove", scenes }, "单体化 remove");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 弹框:三维内置弹框或外部弹框(返回屏幕坐标比例供前端自绘,可随锚点移动)。
|
|
3
|
+
* 内置样式需按项目单独开发,本包只负责协议与发送。
|
|
4
|
+
*/
|
|
5
|
+
import { Action, SendParam } from "./Action";
|
|
6
|
+
|
|
7
|
+
/** create / remove / update / move */
|
|
8
|
+
export type WindowCrudAction = "create" | "remove" | "update" | "move";
|
|
9
|
+
|
|
10
|
+
export type WindowActionType = WindowCrudAction | "getWindowDetails";
|
|
11
|
+
|
|
12
|
+
/** buildIn:三维内弹框;buildOut:前端弹框(接收屏幕坐标比例) */
|
|
13
|
+
export type WindowPopType = "buildIn" | "buildOut";
|
|
14
|
+
|
|
15
|
+
/** 弹框详情行:属性 / 事件 / 服务 */
|
|
16
|
+
export type WindowDetailRowType = "attr" | "event" | "service";
|
|
17
|
+
|
|
18
|
+
/** windowInfo.params 单项 */
|
|
19
|
+
export interface WindowDetailParam {
|
|
20
|
+
/** 默认 attr;为空时三维会按 attr 处理 */
|
|
21
|
+
type?: WindowDetailRowType;
|
|
22
|
+
id?: string;
|
|
23
|
+
value?: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
unit?: string;
|
|
26
|
+
textColor?: string;
|
|
27
|
+
textSize?: number;
|
|
28
|
+
/** 文本是否有背景(协议字段名如此) */
|
|
29
|
+
hasBlackground?: boolean;
|
|
30
|
+
alertIs?: boolean;
|
|
31
|
+
alertTime?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** 弹框主体配置 */
|
|
35
|
+
export interface WindowInfo {
|
|
36
|
+
/** 设备所在场景编码,按项目约定,非必须 */
|
|
37
|
+
sceneCode?: string;
|
|
38
|
+
/** 弹框唯一 id,不传由三维生成 */
|
|
39
|
+
id?: string;
|
|
40
|
+
/** 绑定的三维资产模型 id */
|
|
41
|
+
linkAssetId?: string;
|
|
42
|
+
/** 标题 */
|
|
43
|
+
name?: string;
|
|
44
|
+
/** 设备/弹框类型 */
|
|
45
|
+
type?: string;
|
|
46
|
+
/** 世界坐标;不传则可用 linkAssetId 对应资产坐标 */
|
|
47
|
+
position?: string;
|
|
48
|
+
/** 相对锚点偏移,用于微调 */
|
|
49
|
+
localPosition?: string;
|
|
50
|
+
/** 详情内容;列表时每项一行 */
|
|
51
|
+
params?: WindowDetailParam[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type WindowPayload =
|
|
55
|
+
| {
|
|
56
|
+
action: WindowCrudAction;
|
|
57
|
+
popType: WindowPopType;
|
|
58
|
+
windowInfo: WindowInfo;
|
|
59
|
+
}
|
|
60
|
+
| {
|
|
61
|
+
action: "getWindowDetails";
|
|
62
|
+
/** 如机柜、机柜设备 */
|
|
63
|
+
type: string;
|
|
64
|
+
id: string;
|
|
65
|
+
/** 注意:与 windowInfo.sceneCode 不同,此处协议字段名为 senceCode */
|
|
66
|
+
senceCode: string;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
type WindowParamType = SendParam & {
|
|
70
|
+
cmd: "window";
|
|
71
|
+
data: WindowPayload;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export class WindowAction extends Action {
|
|
75
|
+
private static crud(
|
|
76
|
+
action: WindowCrudAction,
|
|
77
|
+
popType: WindowPopType,
|
|
78
|
+
windowInfo: WindowInfo,
|
|
79
|
+
log: string
|
|
80
|
+
) {
|
|
81
|
+
const data: Extract<WindowPayload, { action: WindowCrudAction }> = {
|
|
82
|
+
action,
|
|
83
|
+
popType,
|
|
84
|
+
windowInfo
|
|
85
|
+
};
|
|
86
|
+
return this.sendParam(
|
|
87
|
+
{ cmd: "window", data } as WindowParamType,
|
|
88
|
+
log
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static createWindow(popType: WindowPopType, windowInfo: WindowInfo) {
|
|
93
|
+
return this.crud("create", popType, windowInfo, `弹框创建 - ${popType}`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static removeWindow(popType: WindowPopType, windowInfo: WindowInfo) {
|
|
97
|
+
return this.crud("remove", popType, windowInfo, `弹框移除 - ${popType}`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static updateWindow(popType: WindowPopType, windowInfo: WindowInfo) {
|
|
101
|
+
return this.crud("update", popType, windowInfo, `弹框更新 - ${popType}`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static moveWindow(popType: WindowPopType, windowInfo: WindowInfo) {
|
|
105
|
+
return this.crud("move", popType, windowInfo, `弹框移动 - ${popType}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 查询弹框详情(按设备类型、设备 id、场景)
|
|
110
|
+
* @param senceCode 协议字段名与 sceneCode 拼写不一致,与三维约定保持一致
|
|
111
|
+
*/
|
|
112
|
+
static getWindowDetails(
|
|
113
|
+
type: string,
|
|
114
|
+
id: string,
|
|
115
|
+
senceCode: string
|
|
116
|
+
) {
|
|
117
|
+
const data: Extract<WindowPayload, { action: "getWindowDetails" }> = {
|
|
118
|
+
action: "getWindowDetails",
|
|
119
|
+
type,
|
|
120
|
+
id,
|
|
121
|
+
senceCode
|
|
122
|
+
};
|
|
123
|
+
return this.sendParam(
|
|
124
|
+
{ cmd: "window", data } as WindowParamType,
|
|
125
|
+
`获取弹框详情 - type: ${type} id: ${id}`
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
}
|