@cpzxrobot/sdk 1.0.11 → 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.
@@ -2,29 +2,29 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CameraGateway = void 0;
4
4
  class CameraGateway extends Object {
5
- constructor(context) {
6
- super();
7
- this.context = context;
8
- }
9
- //搜索摄像头
10
- async search(data) {
11
- var axios = await this.context.ready;
12
- const response = axios.post("/api/v1/camera/search", {
13
- unit_id: data.id,
14
- });
15
- return response.data;
16
- }
17
- //获得摄像头的播放地址
18
- async getUrl(data) {
19
- var axios = await this.context.ready;
20
- const response = axios.get(`/api/v1/camera/${data.id}/url/wss`);
21
- return response.data;
22
- }
23
- //获取工厂天气
24
- async weather(id) {
25
- var axios = await this.context.ready;
26
- const response = axios.get(`/api/v1/weather?code=${id}`);
27
- return response.data;
28
- }
5
+ constructor(context) {
6
+ super();
7
+ this.context = context;
8
+ }
9
+ //搜索摄像头
10
+ async search(data) {
11
+ var axios = await this.context.ready;
12
+ const response = await axios.post("/api/v1/camera/search", {
13
+ unit_id: data.id,
14
+ });
15
+ return response.data;
16
+ }
17
+ //获得摄像头的播放地址
18
+ async getUrl(data) {
19
+ var axios = await this.context.ready;
20
+ const response = await axios.get(`/api/v1/camera/${data.id}/url/wss`);
21
+ return response.data;
22
+ }
23
+ //获取工厂天气
24
+ async weather(id) {
25
+ var axios = await this.context.ready;
26
+ const response = await axios.get(`/api/v1/weather?code=${id}`);
27
+ return response.data;
28
+ }
29
29
  }
30
30
  exports.CameraGateway = CameraGateway;
@@ -94,10 +94,6 @@ class DeviceFilter {
94
94
  sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7);
95
95
  args.start = this.formateDateToYYYYMMDD(sevenDaysAgo);
96
96
  }
97
- if (!args.type) {
98
- throw new Error("没有提交数据类型,请检查type参数");
99
- }
100
-
101
97
  return this.context.ready
102
98
  .then(() => {
103
99
  const p1 = this.context.axios.get(`/api/v1/device/${id}/data/${args.type}`, {
@@ -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":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
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":