@ray-js/api 1.5.14 → 1.5.16
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/lib/cloud/interface.d.ts +317 -16
- package/lib/cloud/interface.js +3 -0
- package/lib/cloud/linkage.d.ts +20 -3
- package/lib/cloud/linkage.js +55 -9
- package/lib/panel/devInfo/index.d.ts +20 -2
- package/lib/panel/devInfo/index.js +80 -16
- package/lib/panel/types/devInfo.d.ts +22 -9
- package/package.json +5 -5
package/lib/cloud/interface.d.ts
CHANGED
@@ -330,36 +330,117 @@ export interface IGetAstronomicalList {
|
|
330
330
|
bizId: string;
|
331
331
|
}
|
332
332
|
export interface IGetAstronomicalListResponse {
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
333
|
+
/**
|
334
|
+
* 日出日落类型
|
335
|
+
*/
|
336
|
+
astronomicalType: number;
|
337
|
+
/**
|
338
|
+
* 设备或群组 ID
|
339
|
+
*/
|
340
|
+
bizId: string;
|
341
|
+
/**
|
342
|
+
* 资源类型。0:单设备。1:群组设备。
|
343
|
+
*/
|
344
|
+
bizType: number;
|
345
|
+
/**
|
346
|
+
* DP 值
|
347
|
+
*/
|
348
|
+
dps: string;
|
349
|
+
/**
|
350
|
+
* 定时任务 ID
|
351
|
+
*/
|
352
|
+
id: number;
|
353
|
+
/**
|
354
|
+
* 经度
|
355
|
+
*/
|
356
|
+
lat: number;
|
357
|
+
/**
|
358
|
+
* 纬度
|
359
|
+
*/
|
360
|
+
lon: number;
|
361
|
+
/**
|
362
|
+
* 周循环
|
363
|
+
*/
|
364
|
+
loops: string;
|
365
|
+
/**
|
366
|
+
* 下一个日出时间
|
367
|
+
*/
|
368
|
+
nextSunSet: string;
|
369
|
+
/**
|
370
|
+
* 定时偏移执行类型
|
371
|
+
*/
|
372
|
+
offsetType: number;
|
373
|
+
/**
|
374
|
+
* 定时任务状态,0 关闭,1 开启,2 无效/已删除
|
375
|
+
*/
|
376
|
+
status: number;
|
377
|
+
/**
|
378
|
+
* 定时时间
|
379
|
+
*/
|
380
|
+
time: string;
|
381
|
+
/**
|
382
|
+
* 时区
|
383
|
+
*/
|
384
|
+
timezone: string;
|
347
385
|
}
|
348
386
|
export interface IAstronomical {
|
387
|
+
/**
|
388
|
+
* 定时任务 ID
|
389
|
+
*/
|
390
|
+
id: number;
|
391
|
+
/**
|
392
|
+
* 设备或群组 ID
|
393
|
+
*/
|
349
394
|
bizId: string;
|
395
|
+
/**
|
396
|
+
* 资源类型。0:单设备。1:群组设备。
|
397
|
+
*/
|
350
398
|
bizType: number;
|
399
|
+
/**
|
400
|
+
* 周循环
|
401
|
+
*/
|
351
402
|
loops: string;
|
352
|
-
|
403
|
+
/**
|
404
|
+
* DP 值
|
405
|
+
*/
|
406
|
+
dps: string;
|
407
|
+
/**
|
408
|
+
* 日出日落类型
|
409
|
+
*/
|
353
410
|
astronomicalType: number;
|
411
|
+
/**
|
412
|
+
* 时区
|
413
|
+
*/
|
354
414
|
timezone: string;
|
415
|
+
/**
|
416
|
+
* 定时日期 yyyyMMdd
|
417
|
+
*/
|
355
418
|
date: string;
|
419
|
+
/**
|
420
|
+
* 定时时间
|
421
|
+
*/
|
356
422
|
time: string;
|
423
|
+
/**
|
424
|
+
* 定时偏移执行类型
|
425
|
+
*/
|
357
426
|
offsetType: number;
|
427
|
+
/**
|
428
|
+
* 经度
|
429
|
+
*/
|
358
430
|
lat: number;
|
431
|
+
/**
|
432
|
+
* 纬度
|
433
|
+
*/
|
359
434
|
lon: number;
|
360
435
|
}
|
361
436
|
export interface IUpdateAstronomicalStatus {
|
437
|
+
/**
|
438
|
+
* 定时任务 ID
|
439
|
+
*/
|
362
440
|
id: string;
|
441
|
+
/**
|
442
|
+
* 0:关闭。1:开启
|
443
|
+
*/
|
363
444
|
status: number;
|
364
445
|
}
|
365
446
|
export interface IUpdateBillConfigure {
|
@@ -875,15 +956,205 @@ export type IGetSceneListResponse = Array<{
|
|
875
956
|
name: string;
|
876
957
|
id: string;
|
877
958
|
}>;
|
959
|
+
export interface ISceneAction {
|
960
|
+
/**
|
961
|
+
* 执行动作的显示名称
|
962
|
+
*/
|
963
|
+
actionDisplay: string;
|
964
|
+
/**
|
965
|
+
* 执行动作的执行者
|
966
|
+
*/
|
967
|
+
actionExecutor: string;
|
968
|
+
/**
|
969
|
+
* 执行动作的策略
|
970
|
+
*/
|
971
|
+
actionStrategy: string;
|
972
|
+
/**
|
973
|
+
* 属性值
|
974
|
+
*/
|
975
|
+
attribute: number;
|
976
|
+
/**
|
977
|
+
* 设备删除标记,表示设备是否被删除
|
978
|
+
*/
|
979
|
+
devDelMark: boolean;
|
980
|
+
/**
|
981
|
+
* 动作是否启用
|
982
|
+
*/
|
983
|
+
enabled: boolean;
|
984
|
+
/**
|
985
|
+
* 实体ID,表示动作所属的实体的ID
|
986
|
+
*/
|
987
|
+
entityId: string;
|
988
|
+
/**
|
989
|
+
* 修改时间戳
|
990
|
+
*/
|
991
|
+
gmtModified: number;
|
992
|
+
/**
|
993
|
+
* 动作的唯一ID
|
994
|
+
*/
|
995
|
+
id: string;
|
996
|
+
/**
|
997
|
+
* 网关同步标记,表示是否网关同步
|
998
|
+
*/
|
999
|
+
offGwSync: boolean;
|
1000
|
+
/**
|
1001
|
+
* 动作的顺序号
|
1002
|
+
*/
|
1003
|
+
orderNum: number;
|
1004
|
+
/**
|
1005
|
+
* 规则ID,表示动作所属的规则的ID
|
1006
|
+
*/
|
1007
|
+
ruleId: string;
|
1008
|
+
/**
|
1009
|
+
* 动作状态
|
1010
|
+
*/
|
1011
|
+
status: boolean;
|
1012
|
+
/**
|
1013
|
+
* 用户ID,表示动作所属的用户的ID
|
1014
|
+
*/
|
1015
|
+
uid: string;
|
1016
|
+
}
|
1017
|
+
/**
|
1018
|
+
* 一键执行类型的联动规则数据
|
1019
|
+
*/
|
1020
|
+
export type IGetSceneListResponseV2 = Array<{
|
1021
|
+
/**
|
1022
|
+
* 执行动作
|
1023
|
+
*/
|
1024
|
+
actions: ISceneAction[];
|
1025
|
+
alarmIssue: boolean;
|
1026
|
+
/**
|
1027
|
+
* 属性
|
1028
|
+
* 根据枚举值的2次幂进行位运算
|
1029
|
+
*/
|
1030
|
+
attribute: number;
|
1031
|
+
/**
|
1032
|
+
* 审核状态
|
1033
|
+
* 0. 未审核
|
1034
|
+
* 1. 审核通过
|
1035
|
+
* 2. 审核不通过
|
1036
|
+
*/
|
1037
|
+
auditStatus: number;
|
1038
|
+
/**
|
1039
|
+
* 背景图地址
|
1040
|
+
*/
|
1041
|
+
background?: string;
|
1042
|
+
/**
|
1043
|
+
* 面板绑定
|
1044
|
+
*/
|
1045
|
+
boundForPanel: boolean;
|
1046
|
+
boundForWiFiPanel: boolean;
|
1047
|
+
/**
|
1048
|
+
* 规则 code
|
1049
|
+
*/
|
1050
|
+
code: string;
|
1051
|
+
/**
|
1052
|
+
* 通用json字段,比如本地联动会存网关id,gwId
|
1053
|
+
*/
|
1054
|
+
commonField: string;
|
1055
|
+
containDeviceDelete: boolean;
|
1056
|
+
/**
|
1057
|
+
* 图标
|
1058
|
+
*/
|
1059
|
+
coverIcon: string;
|
1060
|
+
description?: string;
|
1061
|
+
disableTime?: number;
|
1062
|
+
/**
|
1063
|
+
* 背景颜色
|
1064
|
+
*/
|
1065
|
+
displayColor: string;
|
1066
|
+
/**
|
1067
|
+
* 规则是否启用
|
1068
|
+
*/
|
1069
|
+
enabled: boolean;
|
1070
|
+
forceCloudTrigger: boolean;
|
1071
|
+
/**
|
1072
|
+
* 执行规则 id
|
1073
|
+
*/
|
1074
|
+
id: string;
|
1075
|
+
iotAutoAlarm: boolean;
|
1076
|
+
isAlarmIssue: boolean;
|
1077
|
+
isLogicRule: boolean;
|
1078
|
+
/**
|
1079
|
+
* 联动类型
|
1080
|
+
*/
|
1081
|
+
linkageType: number;
|
1082
|
+
/**
|
1083
|
+
* 是否本地联动
|
1084
|
+
*/
|
1085
|
+
localLinkage: boolean;
|
1086
|
+
logicRule: boolean;
|
1087
|
+
/**
|
1088
|
+
* 匹配类型
|
1089
|
+
* 1. 任意条件,多个条件里只要有一个即触发(即 或关系)。
|
1090
|
+
* 2. 全部满足,多个条件全部满足才触发。
|
1091
|
+
* 3. 表态式匹配, 根据 rule 字段的 expr 确定是否满足,条件满足时触发。
|
1092
|
+
*/
|
1093
|
+
matchType: number;
|
1094
|
+
/**
|
1095
|
+
* 联动名称或备注
|
1096
|
+
*/
|
1097
|
+
name: string;
|
1098
|
+
needCleanGidSid: boolean;
|
1099
|
+
needValidOutOfWork: boolean;
|
1100
|
+
newLocalScene: boolean;
|
1101
|
+
offGwSync: boolean;
|
1102
|
+
offGwSyncSuccess: boolean;
|
1103
|
+
orderWeight: number;
|
1104
|
+
outOfWork: number;
|
1105
|
+
/**
|
1106
|
+
* 家庭id
|
1107
|
+
*/
|
1108
|
+
ownerId: string;
|
1109
|
+
panelType: number;
|
1110
|
+
permissionCode: string;
|
1111
|
+
ruleGenre: number;
|
1112
|
+
ruleSource: number;
|
1113
|
+
/**
|
1114
|
+
* 规则类型
|
1115
|
+
* 1. 系统定义
|
1116
|
+
* 2. 商家定义
|
1117
|
+
* 3. 用户定义
|
1118
|
+
* 4. 安防规则
|
1119
|
+
* 5. 服务定义(如 dp 点转发)
|
1120
|
+
*/
|
1121
|
+
ruleType: number;
|
1122
|
+
/**
|
1123
|
+
* 运行环境
|
1124
|
+
*/
|
1125
|
+
runtimeEnv: string;
|
1126
|
+
scenarioRule: boolean;
|
1127
|
+
status: boolean;
|
1128
|
+
statusConditions: any[];
|
1129
|
+
/**
|
1130
|
+
* 是否显示在首页顶部
|
1131
|
+
*/
|
1132
|
+
stickyOnTop: boolean;
|
1133
|
+
subMatchType: number;
|
1134
|
+
/**
|
1135
|
+
* 用户 id
|
1136
|
+
*/
|
1137
|
+
uid: string;
|
1138
|
+
}>;
|
878
1139
|
export interface IBindRule {
|
879
1140
|
devId: string;
|
1141
|
+
/**
|
1142
|
+
* 与面板/设备建立绑定关系,通常为设备ID、DP点、群组、规则,dpId#value等
|
1143
|
+
*/
|
880
1144
|
sourceEntityId?: string;
|
1145
|
+
/**
|
1146
|
+
* 当associativeEntityId不足以区分情况下使用,通常可关联设备、DP值、群组、规则等
|
1147
|
+
*/
|
881
1148
|
associativeEntityId: AssociativeEntityId;
|
882
1149
|
ruleId: string;
|
883
1150
|
entitySubIds: string;
|
884
1151
|
expr: [string[]];
|
885
1152
|
bizDomain: string;
|
886
1153
|
gid: string;
|
1154
|
+
/**
|
1155
|
+
* 拓展字段,非必传
|
1156
|
+
*/
|
1157
|
+
property?: Record<string, any>;
|
887
1158
|
}
|
888
1159
|
export interface IBindRuleResponse {
|
889
1160
|
/**
|
@@ -931,11 +1202,41 @@ export interface IGetBindRuleList {
|
|
931
1202
|
gid: string;
|
932
1203
|
}
|
933
1204
|
export type IGetBindRuleListResponse = Array<{
|
1205
|
+
/**
|
1206
|
+
* 与面板/设备建立绑定关系,通常为设备ID、DP点、群组、规则,dpId#value等
|
1207
|
+
*/
|
934
1208
|
associativeEntityId: AssociativeEntityId;
|
935
|
-
|
1209
|
+
/**
|
1210
|
+
* 关联实体的值列表
|
1211
|
+
*/
|
1212
|
+
associativeEntityValueList: IGetSceneListResponseV2;
|
1213
|
+
/**
|
1214
|
+
* 绑定 id,一般用来解绑
|
1215
|
+
*/
|
1216
|
+
bindId: number;
|
1217
|
+
/**
|
1218
|
+
* 业务域
|
1219
|
+
*/
|
936
1220
|
bizDomain: string;
|
1221
|
+
/**
|
1222
|
+
* 是否启用
|
1223
|
+
*/
|
1224
|
+
enable: boolean;
|
1225
|
+
/**
|
1226
|
+
* 设备 ID
|
1227
|
+
*/
|
937
1228
|
sourceEntityId: string;
|
938
1229
|
}>;
|
1230
|
+
export interface IUnbindRule {
|
1231
|
+
/**
|
1232
|
+
* 解绑 id
|
1233
|
+
*/
|
1234
|
+
bindId: string;
|
1235
|
+
/**
|
1236
|
+
* 家庭 id
|
1237
|
+
*/
|
1238
|
+
gid: string;
|
1239
|
+
}
|
939
1240
|
export interface IRemoveRule {
|
940
1241
|
bizDomain: string;
|
941
1242
|
sourceEntityId?: string;
|
package/lib/cloud/interface.js
CHANGED
package/lib/cloud/linkage.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { IGetLinkageDeviceList, IBindRule, IGetBindRuleList, IRemoveRule, IGetLinkageDeviceListResponse, IGetSceneListResponse, IGetBindRuleListResponse, IBindRuleResponse } from './interface';
|
1
|
+
import { IGetLinkageDeviceList, IBindRule, IGetBindRuleList, IRemoveRule, IGetLinkageDeviceListResponse, IGetSceneListResponse, IGetBindRuleListResponse, IBindRuleResponse, IUnbindRule, IGetSceneListResponseV2 } from './interface';
|
2
2
|
/**
|
3
3
|
* 获取家庭下支持联动的设备列表
|
4
4
|
* @param {number} gid 家庭id
|
@@ -6,7 +6,7 @@ import { IGetLinkageDeviceList, IBindRule, IGetBindRuleList, IRemoveRule, IGetLi
|
|
6
6
|
*/
|
7
7
|
declare const getLinkageDeviceList: (params: IGetLinkageDeviceList) => Promise<IGetLinkageDeviceListResponse>;
|
8
8
|
/**
|
9
|
-
*
|
9
|
+
* 查询家庭下联动规则列表,包含失效及自动化规则
|
10
10
|
* @param {number} devId 设备id
|
11
11
|
* @param {number} gid 家庭Id
|
12
12
|
*/
|
@@ -14,6 +14,17 @@ declare const getSceneList: ({ devId, gid, }: {
|
|
14
14
|
devId: string;
|
15
15
|
gid: string;
|
16
16
|
}) => Promise<IGetSceneListResponse>;
|
17
|
+
/**
|
18
|
+
* 查询家庭下一键执行列表,会去掉失效或自动化规则
|
19
|
+
* @param {number} devId 设备id
|
20
|
+
* @param {boolean} containStandardZigBee 是否包含标准场景,默认不包含
|
21
|
+
* @param {number} gid 家庭Id
|
22
|
+
*/
|
23
|
+
declare const getSceneListV2: ({ devId, gid, containStandardZigBee, }: {
|
24
|
+
devId: string;
|
25
|
+
gid: string;
|
26
|
+
containStandardZigBee?: boolean;
|
27
|
+
}) => Promise<IGetSceneListResponseV2>;
|
17
28
|
/**
|
18
29
|
* 查询家庭下已绑定的列表
|
19
30
|
* @param {string} bizDomain 业务范围
|
@@ -32,6 +43,12 @@ declare const getBindRuleList: (params: IGetBindRuleList) => Promise<IGetBindRul
|
|
32
43
|
* @param {string} bizDomain 业务域
|
33
44
|
*/
|
34
45
|
declare const bindRule: (params: IBindRule) => Promise<IBindRuleResponse>;
|
46
|
+
/**
|
47
|
+
* 解绑联动
|
48
|
+
* @param {string} bindId 绑定 id
|
49
|
+
* @param {string} gid 家庭id
|
50
|
+
*/
|
51
|
+
declare const unbindRule: (params: IUnbindRule) => Promise<boolean>;
|
35
52
|
/**
|
36
53
|
* 解除联动
|
37
54
|
* @param {string} bizDomain 业务范围
|
@@ -62,4 +79,4 @@ declare const enableRule: ({ ruleId }: {
|
|
62
79
|
declare const disableRule: ({ ruleId }: {
|
63
80
|
ruleId: string;
|
64
81
|
}) => Promise<boolean>;
|
65
|
-
export { getLinkageDeviceList, getSceneList, getBindRuleList, bindRule, removeRule, triggerRule, enableRule, disableRule, };
|
82
|
+
export { getLinkageDeviceList, getSceneList, getSceneListV2, getBindRuleList, bindRule, unbindRule, removeRule, triggerRule, enableRule, disableRule, };
|
package/lib/cloud/linkage.js
CHANGED
@@ -21,7 +21,7 @@ const getLinkageDeviceList = params => {
|
|
21
21
|
};
|
22
22
|
|
23
23
|
/**
|
24
|
-
*
|
24
|
+
* 查询家庭下联动规则列表,包含失效及自动化规则
|
25
25
|
* @param {number} devId 设备id
|
26
26
|
* @param {number} gid 家庭Id
|
27
27
|
*/
|
@@ -42,6 +42,31 @@ const getSceneList = _ref => {
|
|
42
42
|
});
|
43
43
|
};
|
44
44
|
|
45
|
+
/**
|
46
|
+
* 查询家庭下一键执行列表,会去掉失效或自动化规则
|
47
|
+
* @param {number} devId 设备id
|
48
|
+
* @param {boolean} containStandardZigBee 是否包含标准场景,默认不包含
|
49
|
+
* @param {number} gid 家庭Id
|
50
|
+
*/
|
51
|
+
const getSceneListV2 = _ref2 => {
|
52
|
+
let {
|
53
|
+
devId,
|
54
|
+
gid,
|
55
|
+
containStandardZigBee = false
|
56
|
+
} = _ref2;
|
57
|
+
return requestCloud({
|
58
|
+
api: "".concat(THING, ".m.linkage.rule.brief.query"),
|
59
|
+
version: '2.0',
|
60
|
+
data: {
|
61
|
+
devId,
|
62
|
+
containStandardZigBee
|
63
|
+
},
|
64
|
+
extData: {
|
65
|
+
gid: "".concat(gid)
|
66
|
+
}
|
67
|
+
});
|
68
|
+
};
|
69
|
+
|
45
70
|
/**
|
46
71
|
* 查询家庭下已绑定的列表
|
47
72
|
* @param {string} bizDomain 业务范围
|
@@ -86,7 +111,8 @@ const bindRule = params => {
|
|
86
111
|
entitySubIds,
|
87
112
|
expr,
|
88
113
|
bizDomain,
|
89
|
-
gid
|
114
|
+
gid,
|
115
|
+
property
|
90
116
|
} = params;
|
91
117
|
return requestCloud({
|
92
118
|
api: "".concat(THING, ".m.linkage.associative.entity.bind"),
|
@@ -110,6 +136,8 @@ const bindRule = params => {
|
|
110
136
|
actionExecutor: 'ruleTrigger'
|
111
137
|
}]
|
112
138
|
},
|
139
|
+
ruleIds: [ruleId],
|
140
|
+
property,
|
113
141
|
bizDomain,
|
114
142
|
uniqueType: 3
|
115
143
|
}
|
@@ -120,6 +148,24 @@ const bindRule = params => {
|
|
120
148
|
});
|
121
149
|
};
|
122
150
|
|
151
|
+
/**
|
152
|
+
* 解绑联动
|
153
|
+
* @param {string} bindId 绑定 id
|
154
|
+
* @param {string} gid 家庭id
|
155
|
+
*/
|
156
|
+
const unbindRule = params => {
|
157
|
+
return requestCloud({
|
158
|
+
api: "".concat(THING, ".m.linkage.bind.delete"),
|
159
|
+
version: '1.0',
|
160
|
+
data: {
|
161
|
+
bindId: params.bindId
|
162
|
+
},
|
163
|
+
extData: {
|
164
|
+
gid: "".concat(params.gid)
|
165
|
+
}
|
166
|
+
});
|
167
|
+
};
|
168
|
+
|
123
169
|
/**
|
124
170
|
* 解除联动
|
125
171
|
* @param {string} bizDomain 业务范围
|
@@ -151,10 +197,10 @@ const removeRule = params => {
|
|
151
197
|
* 触发联动
|
152
198
|
* @param {string} ruleId 规则id
|
153
199
|
*/
|
154
|
-
const triggerRule =
|
200
|
+
const triggerRule = _ref3 => {
|
155
201
|
let {
|
156
202
|
ruleId
|
157
|
-
} =
|
203
|
+
} = _ref3;
|
158
204
|
return requestCloud({
|
159
205
|
api: "".concat(THING, ".m.linkage.rule.trigger"),
|
160
206
|
version: '1.0',
|
@@ -168,10 +214,10 @@ const triggerRule = _ref2 => {
|
|
168
214
|
* 启用联动
|
169
215
|
* @param {string} ruleId 规则id
|
170
216
|
*/
|
171
|
-
const enableRule =
|
217
|
+
const enableRule = _ref4 => {
|
172
218
|
let {
|
173
219
|
ruleId
|
174
|
-
} =
|
220
|
+
} = _ref4;
|
175
221
|
return requestCloud({
|
176
222
|
api: "".concat(THING, ".m.linkage.rule.enable"),
|
177
223
|
version: '1.0',
|
@@ -185,10 +231,10 @@ const enableRule = _ref3 => {
|
|
185
231
|
* 停用联动
|
186
232
|
* @param {string} ruleId 规则id
|
187
233
|
*/
|
188
|
-
const disableRule =
|
234
|
+
const disableRule = _ref5 => {
|
189
235
|
let {
|
190
236
|
ruleId
|
191
|
-
} =
|
237
|
+
} = _ref5;
|
192
238
|
return requestCloud({
|
193
239
|
api: "".concat(THING, ".m.linkage.rule.disable"),
|
194
240
|
version: '1.0',
|
@@ -197,4 +243,4 @@ const disableRule = _ref4 => {
|
|
197
243
|
}
|
198
244
|
});
|
199
245
|
};
|
200
|
-
export { getLinkageDeviceList, getSceneList, getBindRuleList, bindRule, removeRule, triggerRule, enableRule, disableRule };
|
246
|
+
export { getLinkageDeviceList, getSceneList, getSceneListV2, getBindRuleList, bindRule, unbindRule, removeRule, triggerRule, enableRule, disableRule };
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { DevInfo } from '../types/devInfo';
|
1
|
+
import { DevInfo, GroupInfo } from '../types/devInfo';
|
2
2
|
export interface InitPanelEnvironmentOptions {
|
3
3
|
/**
|
4
4
|
* @description 是否需要使用默认离线弹窗
|
@@ -40,10 +40,21 @@ export interface InitPanelEnvironmentOptions {
|
|
40
40
|
* @default undefined
|
41
41
|
*/
|
42
42
|
groupId?: string;
|
43
|
+
/**
|
44
|
+
* 微信详细页面路由
|
45
|
+
* @default undefined
|
46
|
+
*/
|
47
|
+
deviceDetailPage?: string;
|
48
|
+
/**
|
49
|
+
*是否显示故障提示
|
50
|
+
* @default false
|
51
|
+
*/
|
52
|
+
showFault?: boolean;
|
43
53
|
}
|
44
54
|
export declare function parseDevice(dev: ty.device.DeviceInfo | DevInfo): DevInfo;
|
55
|
+
export declare function parseGroup(group: ty.device.GroupInfo): GroupInfo;
|
45
56
|
/**
|
46
|
-
*
|
57
|
+
* 初始化面板环境下使用到的设备或群组信息
|
47
58
|
* @returns Promise<DevInfo>
|
48
59
|
*/
|
49
60
|
export declare const initDevInfo: (option?: {
|
@@ -57,3 +68,10 @@ export declare const updateDevInfo: (devInfo: DevInfo) => void;
|
|
57
68
|
* @param config: InitPanelEnvironmentOptions 配置项
|
58
69
|
*/
|
59
70
|
export declare function initPanelEnvironment(options?: InitPanelEnvironmentOptions): Promise<void>;
|
71
|
+
/**
|
72
|
+
* 初始化面板环境
|
73
|
+
* @param options 一些配置
|
74
|
+
* @param initCallback 初始化回调整
|
75
|
+
* @param destroyCallback 销毁环境回调整
|
76
|
+
*/
|
77
|
+
export declare const useInitPanelEnv: (options?: InitPanelEnvironmentOptions, initCallback?: (devId: string) => any, destroyCallback?: (devId: string) => any) => void;
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
2
|
import { getDeviceInfo, getLaunchOptionsSync, getGroupInfo, registerDeviceListListener, registerGroupChange, exitMiniProgram, subscribeDeviceRemoved, onDeviceRemoved } from '../../all-kits';
|
3
|
+
import { useEffect } from 'react';
|
3
4
|
import getApp from '../../getApp';
|
5
|
+
|
4
6
|
// 本地化缓存 deviceInfo 方便随时调用
|
5
7
|
let __deviceInfo = null;
|
6
8
|
const defaultPanelEnvironmentOptions = {
|
@@ -8,14 +10,15 @@ const defaultPanelEnvironmentOptions = {
|
|
8
10
|
bleCover: false,
|
9
11
|
customTop: null,
|
10
12
|
bleConnectType: 0,
|
11
|
-
showBLEToast: true
|
13
|
+
showBLEToast: true,
|
14
|
+
showFault: false
|
12
15
|
};
|
13
16
|
export function parseDevice(dev) {
|
14
17
|
if (!dev) return null;
|
15
|
-
// @ts-ignore
|
16
18
|
const deviceInfo = _objectSpread({}, dev);
|
19
|
+
// tuyalink 协议设备没有 schema 字段。避免崩溃加设置为空数组
|
17
20
|
const {
|
18
|
-
schema
|
21
|
+
schema = []
|
19
22
|
} = dev;
|
20
23
|
const idCodes = {};
|
21
24
|
const codeIds = {};
|
@@ -32,26 +35,50 @@ export function parseDevice(dev) {
|
|
32
35
|
deviceInfo.codeIds = codeIds;
|
33
36
|
return deviceInfo;
|
34
37
|
}
|
38
|
+
export function parseGroup(group) {
|
39
|
+
if (!group) return null;
|
40
|
+
const groupInfo = _objectSpread({}, group);
|
41
|
+
const {
|
42
|
+
schema
|
43
|
+
} = group;
|
44
|
+
const idCodes = {};
|
45
|
+
const codeIds = {};
|
46
|
+
schema.forEach(item => {
|
47
|
+
// @ts-ignore
|
48
|
+
const {
|
49
|
+
id,
|
50
|
+
code
|
51
|
+
} = item;
|
52
|
+
idCodes[id] = code;
|
53
|
+
codeIds[code] = id;
|
54
|
+
});
|
55
|
+
groupInfo.idCodes = idCodes;
|
56
|
+
groupInfo.codeIds = codeIds;
|
57
|
+
return groupInfo;
|
58
|
+
}
|
35
59
|
|
36
60
|
/**
|
37
|
-
*
|
61
|
+
* 初始化面板环境下使用到的设备或群组信息
|
38
62
|
* @returns Promise<DevInfo>
|
39
63
|
*/
|
40
64
|
export const initDevInfo = option => {
|
41
65
|
return new Promise((resolve, reject) => {
|
66
|
+
var _data$query, _data$query2;
|
42
67
|
if (__deviceInfo) {
|
43
68
|
resolve(__deviceInfo);
|
44
69
|
}
|
45
70
|
const data = getLaunchOptionsSync();
|
46
|
-
|
71
|
+
let {
|
47
72
|
deviceId,
|
48
73
|
groupId
|
49
|
-
} = option ||
|
74
|
+
} = option || {};
|
75
|
+
deviceId = deviceId || ((_data$query = data.query) === null || _data$query === void 0 ? void 0 : _data$query.deviceId);
|
76
|
+
groupId = groupId || ((_data$query2 = data.query) === null || _data$query2 === void 0 ? void 0 : _data$query2.groupId);
|
50
77
|
if (groupId) {
|
51
78
|
getGroupInfo({
|
52
79
|
groupId,
|
53
80
|
success: groupInfo => {
|
54
|
-
__deviceInfo = groupInfo;
|
81
|
+
__deviceInfo = parseDevice(groupInfo);
|
55
82
|
resolve(__deviceInfo);
|
56
83
|
}
|
57
84
|
});
|
@@ -95,19 +122,14 @@ export async function initPanelEnvironment() {
|
|
95
122
|
});
|
96
123
|
return;
|
97
124
|
}
|
125
|
+
let init = false;
|
98
126
|
const App = getApp();
|
99
|
-
|
100
|
-
// 基础库版本需要大于 2.6.0
|
101
|
-
// @ts-ignore
|
102
|
-
App.onReady = event => {
|
127
|
+
const initPanel = event => {
|
103
128
|
var _options$deviceId, _options$groupId;
|
104
129
|
const deviceId = (_options$deviceId = options.deviceId) !== null && _options$deviceId !== void 0 ? _options$deviceId : event.query.deviceId;
|
105
130
|
const groupId = (_options$groupId = options.groupId) !== null && _options$groupId !== void 0 ? _options$groupId : event.query.groupId;
|
106
|
-
const {
|
107
|
-
useDefaultOffline
|
108
|
-
} = options;
|
109
131
|
// @ts-ignore
|
110
|
-
if (ty.panel && ty.panel.initPanelKit
|
132
|
+
if (ty.panel && ty.panel.initPanelKit) {
|
111
133
|
// @ts-ignore
|
112
134
|
ty.panel.initPanelKit(_objectSpread({
|
113
135
|
deviceId,
|
@@ -136,6 +158,48 @@ export async function initPanelEnvironment() {
|
|
136
158
|
});
|
137
159
|
}
|
138
160
|
};
|
161
|
+
// 由于手机性能、初始化方法调用时机、框架初始化及界面加载逻辑的差异,
|
162
|
+
// 有时注册 App.onReady 时可能当前界面已经执行完了该事件,导致逻辑无法正常执行。因此增加延时逻辑,保证逻辑正常执行
|
163
|
+
// 若 3s 后仍未执行,则认为当前界面已经执行完了 App.onReady,直接执行逻辑
|
164
|
+
const timeout = setTimeout(() => {
|
165
|
+
if (init) return;
|
166
|
+
initPanel(getLaunchOptionsSync());
|
167
|
+
}, 3000);
|
168
|
+
// 基础库版本需要大于 2.6.0
|
169
|
+
// @ts-ignore
|
170
|
+
App.onReady = event => {
|
171
|
+
init = true;
|
172
|
+
clearTimeout(timeout);
|
173
|
+
initPanel(event);
|
174
|
+
};
|
175
|
+
|
139
176
|
// 使用 Promise 确保业务可以通过 initPanelEnvironment 的正常调用明确设备信息初始化完成
|
140
177
|
await initDevInfo(options.deviceId || options.groupId ? options : undefined);
|
141
|
-
}
|
178
|
+
}
|
179
|
+
|
180
|
+
/**
|
181
|
+
* 初始化面板环境
|
182
|
+
* @param options 一些配置
|
183
|
+
* @param initCallback 初始化回调整
|
184
|
+
* @param destroyCallback 销毁环境回调整
|
185
|
+
*/
|
186
|
+
export const useInitPanelEnv = function () {
|
187
|
+
var _data$query3, _data$query4;
|
188
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultPanelEnvironmentOptions;
|
189
|
+
let initCallback = arguments.length > 1 ? arguments[1] : undefined;
|
190
|
+
let destroyCallback = arguments.length > 2 ? arguments[2] : undefined;
|
191
|
+
const data = getLaunchOptionsSync();
|
192
|
+
let {
|
193
|
+
deviceId,
|
194
|
+
groupId
|
195
|
+
} = options || {};
|
196
|
+
deviceId = deviceId || ((_data$query3 = data.query) === null || _data$query3 === void 0 ? void 0 : _data$query3.deviceId);
|
197
|
+
groupId = groupId || ((_data$query4 = data.query) === null || _data$query4 === void 0 ? void 0 : _data$query4.groupId);
|
198
|
+
initPanelEnvironment(options);
|
199
|
+
useEffect(() => {
|
200
|
+
initCallback && initCallback(deviceId || groupId);
|
201
|
+
return () => {
|
202
|
+
destroyCallback && destroyCallback(deviceId || groupId);
|
203
|
+
};
|
204
|
+
}, []);
|
205
|
+
};
|
@@ -1,21 +1,21 @@
|
|
1
1
|
export type DpValue = boolean | number | string;
|
2
2
|
export type DpState = Record<string, DpValue>;
|
3
3
|
export interface DpSchema {
|
4
|
-
attr
|
5
|
-
canTrigger
|
4
|
+
attr?: number;
|
5
|
+
canTrigger?: boolean;
|
6
6
|
/**
|
7
7
|
* 功能点标识码,如 switch
|
8
8
|
*/
|
9
9
|
code: string;
|
10
|
-
defaultRecommend
|
11
|
-
editPermission
|
12
|
-
executable
|
13
|
-
extContent
|
14
|
-
iconname
|
10
|
+
defaultRecommend?: boolean;
|
11
|
+
editPermission?: boolean;
|
12
|
+
executable?: boolean;
|
13
|
+
extContent?: string;
|
14
|
+
iconname?: string;
|
15
15
|
/**
|
16
16
|
* 功能点 ID
|
17
17
|
*/
|
18
|
-
id: number;
|
18
|
+
id: number | string;
|
19
19
|
/**
|
20
20
|
* 功能点模式类型
|
21
21
|
* rw: 可下发可上报(可读可写)
|
@@ -34,7 +34,7 @@ export interface DpSchema {
|
|
34
34
|
/**
|
35
35
|
* 功能点类型
|
36
36
|
*/
|
37
|
-
type: 'bool' | 'value' | 'enum' | 'bitmap' | 'string';
|
37
|
+
type: 'bool' | 'value' | 'enum' | 'bitmap' | 'string' | 'raw';
|
38
38
|
/**
|
39
39
|
* 枚举值范围,type = enum 时才存在
|
40
40
|
*/
|
@@ -103,4 +103,17 @@ export type DevInfo = Omit<ty.device.DeviceInfo, 'schema' | 'panelConfig'> & {
|
|
103
103
|
*/
|
104
104
|
panelConfig: PanelConfig;
|
105
105
|
};
|
106
|
+
/**
|
107
|
+
* 群组信息
|
108
|
+
*/
|
109
|
+
export type GroupInfo = ty.device.GroupInfo & {
|
110
|
+
/**
|
111
|
+
* dp id 与 dp code 的映射
|
112
|
+
*/
|
113
|
+
idCodes: Record<string, string>;
|
114
|
+
/**
|
115
|
+
* dp code 与 dp id 的映射
|
116
|
+
*/
|
117
|
+
codeIds: Record<string, string>;
|
118
|
+
};
|
106
119
|
export {};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ray-js/api",
|
3
|
-
"version": "1.5.
|
3
|
+
"version": "1.5.16",
|
4
4
|
"description": "Ray universal api",
|
5
5
|
"keywords": [
|
6
6
|
"ray"
|
@@ -29,14 +29,14 @@
|
|
29
29
|
"watch": "ray start --type=component"
|
30
30
|
},
|
31
31
|
"dependencies": {
|
32
|
-
"@ray-js/framework": "1.5.
|
33
|
-
"@ray-js/router": "1.5.
|
32
|
+
"@ray-js/framework": "1.5.16",
|
33
|
+
"@ray-js/router": "1.5.16",
|
34
34
|
"@ray-js/wechat": "^0.2.9",
|
35
35
|
"base64-browser": "^1.0.1",
|
36
36
|
"query-string": "^7.1.3"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
|
-
"@ray-js/cli": "1.5.
|
39
|
+
"@ray-js/cli": "1.5.16",
|
40
40
|
"art-template": "^4.13.2",
|
41
41
|
"fs-extra": "^10.1.0",
|
42
42
|
"miniprogram-api-typings": "^3.12.2",
|
@@ -46,5 +46,5 @@
|
|
46
46
|
"access": "public",
|
47
47
|
"registry": "https://registry.npmjs.org"
|
48
48
|
},
|
49
|
-
"gitHead": "
|
49
|
+
"gitHead": "ce198714e778b994aa70f43f2546e132b509feaf"
|
50
50
|
}
|