@cpzxrobot/sdk 1.2.65 → 1.2.66

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,6 +202,10 @@ 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);
207
+ }
208
+
205
209
  private getFilter<T extends { id: number }>(
206
210
  type: string,
207
211
  cls: new (context: Cpzxrobot) => DeviceFilter<T>
@@ -154,6 +154,9 @@ 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);
159
+ }
157
160
  getFilter(type, cls) {
158
161
  if (this.filters.has(type)) {
159
162
  return this.filters.get(type);
package/dist/index.js CHANGED
@@ -242,6 +242,8 @@ class Cpzxrobot {
242
242
  this.setError = window.miniapp.setError;
243
243
  // @ts-ignore
244
244
  this.setProgress = window.miniapp.setProgress;
245
+ // @ts-ignore
246
+ this.shareDevice = window.miniapp.shareDevice;
245
247
  }
246
248
  else if (domain == "appassets.androidplatform.net" || domain == "webc.cpzxrobot.com" ||
247
249
  this.isIosMiniApp(window.location)) {
@@ -281,6 +283,9 @@ class Cpzxrobot {
281
283
  this.vibrate = function (time) {
282
284
  return platform.callHandler("app.vibrate", time);
283
285
  };
286
+ this.shareDevice = function (deviceId) {
287
+ return platform.callHandler("app.shareDevice", deviceId);
288
+ };
284
289
  this.reloadGroup = function (group) {
285
290
  return platform.callHandler("app.reloadGroup", group);
286
291
  };
@@ -403,6 +408,9 @@ class Cpzxrobot {
403
408
  }
404
409
  });
405
410
  };
411
+ this.shareDevice = function (deviceId) {
412
+ return this.axios.get("/api/v1/device/share/" + deviceId);
413
+ };
406
414
  }
407
415
  }
408
416
  isIosMiniApp(location) {
package/index.ts CHANGED
@@ -20,7 +20,7 @@ import { LogsGateway } from "./logs_gateway";
20
20
  import { RobotGateway } from "./robot_gateway";
21
21
  import { QuotationGateway } from "./quotation_gateway";
22
22
  import { AiGateway } from "./ai_gateway";
23
- import { ConstructionGateway } from "./construction_gateway";
23
+ import { ConstructionGateway } from "./construction_gateway";
24
24
  import { SystemGateway } from "./system_gateway";
25
25
 
26
26
  export class Cpzxrobot {
@@ -51,6 +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
55
  reloadGroup!: (key: string) => void;
55
56
  getGeo!: () => Promise<{
56
57
  lat: number;
@@ -119,7 +120,7 @@ export class Cpzxrobot {
119
120
  ...init,
120
121
  headers
121
122
  });
122
-
123
+
123
124
  if (!response.ok) {
124
125
  throw new Error(`HTTP error! status: ${response.status}`);
125
126
  }
@@ -142,7 +143,7 @@ export class Cpzxrobot {
142
143
  });
143
144
  return result;
144
145
  };
145
-
146
+
146
147
  const flattened = flattenParams(config.params);
147
148
  url += "?" + new URLSearchParams(flattened).toString();
148
149
  delete config.params;
@@ -263,6 +264,8 @@ export class Cpzxrobot {
263
264
  this.setError = window.miniapp.setError;
264
265
  // @ts-ignore
265
266
  this.setProgress = window.miniapp.setProgress;
267
+ // @ts-ignore
268
+ this.shareDevice = window.miniapp.shareDevice;
266
269
  } else if (
267
270
  domain == "appassets.androidplatform.net" || domain == "webc.cpzxrobot.com" ||
268
271
  this.isIosMiniApp(window.location)
@@ -305,6 +308,9 @@ export class Cpzxrobot {
305
308
  this.vibrate = function (time?: number) {
306
309
  return platform.callHandler("app.vibrate", time);
307
310
  };
311
+ this.shareDevice = function (deviceId: number) {
312
+ return platform.callHandler("app.shareDevice", deviceId);
313
+ };
308
314
  this.reloadGroup = function (group: string) {
309
315
  return platform.callHandler("app.reloadGroup", group);
310
316
  };
@@ -431,6 +437,9 @@ export class Cpzxrobot {
431
437
  }
432
438
  });
433
439
  };
440
+ this.shareDevice = function (deviceId: number) {
441
+ return this.axios.get("/api/v1/device/share/" + deviceId);
442
+ };
434
443
  }
435
444
  }
436
445
  isIosMiniApp(location: Location): boolean {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.2.65",
3
+ "version": "1.2.66",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/types.d.ts CHANGED
@@ -363,6 +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
367
  }
367
368
 
368
369
  declare global {