@cpzxrobot/sdk 1.2.67 → 1.2.69

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/device_gateway.ts CHANGED
@@ -202,19 +202,29 @@ export class DeviceGateway extends Object {
202
202
  return this.getFilter("ElectricMeter", ElectricMeterGateway);
203
203
  }
204
204
 
205
- share(id: number){
206
- this.context.shareDevice(id);
205
+ //获取设备详情
206
+ //ID:点位ID,设备UUID,当type是device时,为设备ID(UUID);当type是datapoint时,为点位ID(number)
207
+ show(id: any, type: "device"|"datapoint" = "datapoint"){
208
+ this.context.showInDeviceManager(id,type);
207
209
  }
208
210
 
209
211
  private getFilter<T extends { id: number }>(
210
212
  type: string,
211
213
  cls: new (context: Cpzxrobot) => DeviceFilter<T>
212
214
  ): DeviceFilter<T> {
215
+ // 如果filters中已经有对应type的过滤器,则直接返回该过滤器
213
216
  if (this.filters.has(type)) {
214
217
  return this.filters.get(type) as DeviceFilter<T>;
215
218
  }
219
+
220
+ // 否则,创建一个新的过滤器实例
216
221
  const filter = new cls(this.context);
222
+
223
+ // 将新创建的过滤器实例添加到filters中,并返回该过滤器实例
224
+ // 将新创建的过滤器实例添加到filters中
217
225
  this.filters.set(type, filter);
226
+
227
+ // 返回新创建的过滤器实例
218
228
  return filter;
219
229
  }
220
230
 
@@ -154,15 +154,22 @@ class DeviceGateway extends Object {
154
154
  get electricMeter() {
155
155
  return this.getFilter("ElectricMeter", electricmeter_1.ElectricMeterGateway);
156
156
  }
157
- share(id) {
158
- this.context.shareDevice(id);
157
+ //获取设备详情
158
+ //ID:点位ID,设备UUID,当type是device时,为设备ID(UUID);当type是datapoint时,为点位ID(number)
159
+ show(id, type = "datapoint") {
160
+ this.context.showInDeviceManager(id, type);
159
161
  }
160
162
  getFilter(type, cls) {
163
+ // 如果filters中已经有对应type的过滤器,则直接返回该过滤器
161
164
  if (this.filters.has(type)) {
162
165
  return this.filters.get(type);
163
166
  }
167
+ // 否则,创建一个新的过滤器实例
164
168
  const filter = new cls(this.context);
169
+ // 将新创建的过滤器实例添加到filters中,并返回该过滤器实例
170
+ // 将新创建的过滤器实例添加到filters中
165
171
  this.filters.set(type, filter);
172
+ // 返回新创建的过滤器实例
166
173
  return filter;
167
174
  }
168
175
  // addDevice(device: Device) {
package/dist/index.js CHANGED
@@ -119,7 +119,7 @@ class Cpzxrobot {
119
119
  if (value && typeof value === 'object' && !Array.isArray(value)) {
120
120
  Object.assign(result, flattenParams(value, fullKey));
121
121
  }
122
- else {
122
+ else if (value) {
123
123
  result[fullKey] = value.toString();
124
124
  }
125
125
  });
@@ -243,7 +243,7 @@ class Cpzxrobot {
243
243
  // @ts-ignore
244
244
  this.setProgress = window.miniapp.setProgress;
245
245
  // @ts-ignore
246
- this.shareDevice = window.miniapp.shareDevice;
246
+ this.showInDeviceManager = window.miniapp.showInDeviceManager;
247
247
  }
248
248
  else if (domain == "appassets.androidplatform.net" || domain == "webc.cpzxrobot.com" ||
249
249
  this.isIosMiniApp(window.location)) {
@@ -283,8 +283,8 @@ class Cpzxrobot {
283
283
  this.vibrate = function (time) {
284
284
  return platform.callHandler("app.vibrate", time);
285
285
  };
286
- this.shareDevice = function (deviceId) {
287
- return platform.callHandler("app.shareDevice", deviceId);
286
+ this.showInDeviceManager = function (deviceId, type) {
287
+ return platform.callHandler("app.showInDeviceManager", deviceId, type);
288
288
  };
289
289
  this.reloadGroup = function (group) {
290
290
  return platform.callHandler("app.reloadGroup", group);
@@ -408,8 +408,8 @@ class Cpzxrobot {
408
408
  }
409
409
  });
410
410
  };
411
- this.shareDevice = function (deviceId) {
412
- return this.axios.get("/api/v1/device/share/" + deviceId);
411
+ this.showInDeviceManager = function (deviceId, type) {
412
+ return this.axios.get(`/api/v1/${type}/share/` + deviceId);
413
413
  };
414
414
  }
415
415
  }
package/index.ts CHANGED
@@ -51,7 +51,7 @@ export class Cpzxrobot {
51
51
  saveBlob!: (blob: Blob, filename: string) => Promise<void>;
52
52
  scanQrcode!: () => Promise<string>;
53
53
  vibrate!: (time?: number) => void;
54
- shareDevice!: (deviceId: number) => Promise<void>;
54
+ showInDeviceManager!: (deviceId: any, type: string) => Promise<void>;
55
55
  reloadGroup!: (key: string) => void;
56
56
  getGeo!: () => Promise<{
57
57
  lat: number;
@@ -137,7 +137,7 @@ export class Cpzxrobot {
137
137
  const fullKey = prefix ? `${prefix}[${key}]` : key;
138
138
  if (value && typeof value === 'object' && !Array.isArray(value)) {
139
139
  Object.assign(result, flattenParams(value, fullKey));
140
- } else {
140
+ } else if(value){
141
141
  result[fullKey] = value.toString();
142
142
  }
143
143
  });
@@ -265,7 +265,7 @@ export class Cpzxrobot {
265
265
  // @ts-ignore
266
266
  this.setProgress = window.miniapp.setProgress;
267
267
  // @ts-ignore
268
- this.shareDevice = window.miniapp.shareDevice;
268
+ this.showInDeviceManager = window.miniapp.showInDeviceManager;
269
269
  } else if (
270
270
  domain == "appassets.androidplatform.net" || domain == "webc.cpzxrobot.com" ||
271
271
  this.isIosMiniApp(window.location)
@@ -308,8 +308,8 @@ export class Cpzxrobot {
308
308
  this.vibrate = function (time?: number) {
309
309
  return platform.callHandler("app.vibrate", time);
310
310
  };
311
- this.shareDevice = function (deviceId: number) {
312
- return platform.callHandler("app.shareDevice", deviceId);
311
+ this.showInDeviceManager = function (deviceId: number,type:string) {
312
+ return platform.callHandler("app.showInDeviceManager", deviceId,type);
313
313
  };
314
314
  this.reloadGroup = function (group: string) {
315
315
  return platform.callHandler("app.reloadGroup", group);
@@ -437,8 +437,8 @@ export class Cpzxrobot {
437
437
  }
438
438
  });
439
439
  };
440
- this.shareDevice = function (deviceId: number) {
441
- return this.axios.get("/api/v1/device/share/" + deviceId);
440
+ this.showInDeviceManager = function (deviceId: number,type: string) {
441
+ return this.axios.get(`/api/v1/${type}/share/` + deviceId);
442
442
  };
443
443
  }
444
444
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.2.67",
3
+ "version": "1.2.69",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/types.d.ts CHANGED
@@ -363,7 +363,7 @@ class Cpzxrobot {
363
363
  vibrate: (time?: number) => void;
364
364
  reloadGroup: (key: string) => void;
365
365
  getGeo: () => Promise<{ lat: number; lng: number }>;
366
- shareDevice: (deviceId: number) => Promise<void>;
366
+ showInDeviceManager: (deviceId: number, type: string) => Promise<void>;
367
367
  }
368
368
 
369
369
  declare global {