@cpzxrobot/sdk 1.0.10 → 1.0.12

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/camera_gateway.ts CHANGED
@@ -8,8 +8,8 @@ export class CameraGateway extends Object {
8
8
  }
9
9
  //搜索摄像头
10
10
  async search(data: Unit): Promise<any> {
11
- await this.context.ready;
12
- const response = await this.context.axios.post("/api/v1/camera/search", {
11
+ var axios = await this.context.ready;
12
+ const response = await axios.post("/api/v1/camera/search", {
13
13
  unit_id: data.id,
14
14
  });
15
15
  return response.data;
@@ -17,16 +17,16 @@ export class CameraGateway extends Object {
17
17
 
18
18
  //获得摄像头的播放地址
19
19
  async getUrl(data: Camera): Promise<any> {
20
- await this.context.ready;
21
- const response = await this.context.axios.get(
20
+ var axios = await this.context.ready;
21
+ const response = await axios.get(
22
22
  `/api/v1/camera/${data.id}/url/wss`
23
23
  );
24
24
  return response.data;
25
25
  }
26
26
  //获取工厂天气
27
27
  async weather(id: number): Promise<any> {
28
- await this.context.ready;
29
- const response = await this.context.axios.get(`/api/v1/weather?code=${id}`);
28
+ var axios = await this.context.ready;
29
+ const response = await axios.get(`/api/v1/weather?code=${id}`);
30
30
  return response.data;
31
31
  }
32
32
  }
@@ -8,22 +8,22 @@ class CameraGateway extends Object {
8
8
  }
9
9
  //搜索摄像头
10
10
  async search(data) {
11
- await this.context.ready;
12
- const response = await this.context.axios.post("/api/v1/camera/search", {
11
+ var axios = await this.context.ready;
12
+ const response = await axios.post("/api/v1/camera/search", {
13
13
  unit_id: data.id,
14
14
  });
15
15
  return response.data;
16
16
  }
17
17
  //获得摄像头的播放地址
18
18
  async getUrl(data) {
19
- await this.context.ready;
20
- const response = await this.context.axios.get(`/api/v1/camera/${data.id}/url/wss`);
19
+ var axios = await this.context.ready;
20
+ const response = await axios.get(`/api/v1/camera/${data.id}/url/wss`);
21
21
  return response.data;
22
22
  }
23
23
  //获取工厂天气
24
24
  async weather(id) {
25
- await this.context.ready;
26
- const response = await this.context.axios.get(`/api/v1/weather?code=${id}`);
25
+ var axios = await this.context.ready;
26
+ const response = await axios.get(`/api/v1/weather?code=${id}`);
27
27
  return response.data;
28
28
  }
29
29
  }
@@ -42,8 +42,8 @@ class FactoryGateway extends Object {
42
42
  return response.data;
43
43
  }
44
44
  async company(data) {
45
- await this.context.ready;
46
- const response = await this.context.axios.get(`/api/v1/factory/${data.id}/organizaion`, data);
45
+ var axios = await this.context.ready;
46
+ const response = await axios.get(`/api/v1/factory/${data.id}/organizaion`, data);
47
47
  return response.data;
48
48
  }
49
49
  }
@@ -17,7 +17,8 @@ class UserGateway extends Object {
17
17
  this.context = context;
18
18
  }
19
19
  //获得当前用户选择的工厂
20
- getSelectedFarm() {
20
+ async getSelectedFarm() {
21
+ await this.context.ready;
21
22
  return new Promise((resolve, reject) => {
22
23
  switch (this.context.mode) {
23
24
  case "dev":
@@ -47,8 +47,8 @@ export class FactoryGateway extends Object {
47
47
  }
48
48
 
49
49
  async company(data: Factory): Promise<any> {
50
- await this.context.ready;
51
- const response = await this.context.axios.get(`/api/v1/factory/${data.id}/organizaion`, data);
50
+ var axios = await this.context.ready;
51
+ const response = await axios.get(`/api/v1/factory/${data.id}/organizaion`, data);
52
52
  return response.data;
53
53
  }
54
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/types.d.ts CHANGED
@@ -2,6 +2,7 @@ import { DeviceGateway } from "@cpzxrobot/sdk/device_gateway";
2
2
  import { FactoryGateway } from "@cpzxrobot/sdk/factory_gateway";
3
3
  import { TransportGateway } from "@cpzxrobot/sdk/transport_gateway";
4
4
  import { UserGateway } from "@cpzxrobot/sdk/user_gateway";
5
+ import { CameraGateway } from "@cpzxrobot/sdk/camera_gateway";
5
6
 
6
7
  type Device = {
7
8
  id: number;
@@ -130,6 +131,7 @@ export class Cpzxrobot {
130
131
  device: DeviceGateway;
131
132
  mode: string;
132
133
  axios: MyAxiosInstance;
134
+ camera: CameraGateway;
133
135
  _getSelectedFarmFromMiniApp: () => Promise<Factory>;
134
136
  _getSelectedUnitFromMiniApp: () => Promise<Unit>;
135
137
  setTitle: (title: string) => void;
package/user_gateway.ts CHANGED
@@ -19,7 +19,8 @@ export class UserGateway extends Object {
19
19
  }
20
20
 
21
21
  //获得当前用户选择的工厂
22
- public getSelectedFarm(): Promise<Factory> {
22
+ public async getSelectedFarm(): Promise<Factory> {
23
+ await this.context.ready;
23
24
  return new Promise<Factory>((resolve, reject) => {
24
25
  switch (this.context.mode) {
25
26
  case "dev":