@cpzxrobot/sdk 1.0.9 → 1.0.11
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 +6 -6
- package/dist/camera_gateway.js +24 -24
- package/dist/device_filter.js +4 -0
- package/dist/index.js +2 -1
- package/factory_gateway.ts +2 -2
- package/index.ts +2 -1
- package/package.json +1 -1
- package/types.d.ts +2 -0
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
|
|
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
|
|
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
|
|
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
|
}
|
package/dist/camera_gateway.js
CHANGED
|
@@ -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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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 = 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
|
+
}
|
|
29
29
|
}
|
|
30
30
|
exports.CameraGateway = CameraGateway;
|
package/dist/device_filter.js
CHANGED
|
@@ -94,6 +94,10 @@ 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
|
+
|
|
97
101
|
return this.context.ready
|
|
98
102
|
.then(() => {
|
|
99
103
|
const p1 = this.context.axios.get(`/api/v1/device/${id}/data/${args.type}`, {
|
package/dist/index.js
CHANGED
|
@@ -67,10 +67,11 @@ class Cpzxrobot {
|
|
|
67
67
|
}
|
|
68
68
|
_saveBlobAsBase64(blob, filename) {
|
|
69
69
|
const reader = new FileReader();
|
|
70
|
+
var that = this;
|
|
70
71
|
reader.onload = function () {
|
|
71
72
|
const base64 = reader.result;
|
|
72
73
|
// @ts-ignore
|
|
73
|
-
|
|
74
|
+
that.saveBase64(base64, filename);
|
|
74
75
|
};
|
|
75
76
|
reader.readAsDataURL(blob);
|
|
76
77
|
}
|
package/factory_gateway.ts
CHANGED
|
@@ -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
|
|
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/index.ts
CHANGED
|
@@ -92,10 +92,11 @@ export class Cpzxrobot {
|
|
|
92
92
|
|
|
93
93
|
_saveBlobAsBase64(blob: Blob, filename: string) {
|
|
94
94
|
const reader = new FileReader();
|
|
95
|
+
var that = this;
|
|
95
96
|
reader.onload = function () {
|
|
96
97
|
const base64 = reader.result as string;
|
|
97
98
|
// @ts-ignore
|
|
98
|
-
|
|
99
|
+
that.saveBase64(base64, filename);
|
|
99
100
|
};
|
|
100
101
|
reader.readAsDataURL(blob);
|
|
101
102
|
}
|
package/package.json
CHANGED
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;
|