@cpzxrobot/sdk 1.0.24 → 1.0.25

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/dist/index.js CHANGED
@@ -128,15 +128,25 @@ class Cpzxrobot {
128
128
  return platform.callHandler("axios_post", url, data);
129
129
  },
130
130
  };
131
- this.platformReady = new Promise((resolve, reject) => {
132
- window.addEventListener("flutterInAppWebViewPlatformReady", function () {
133
- console.log("flutter android/ios platform is ready");
134
- resolve(true);
131
+ if (
132
+ // @ts-ignore
133
+ window.flutter_inappwebview != null &&
134
+ // @ts-ignore
135
+ window.flutter_inappwebview.callHandler != null) {
136
+ this.platformReady = Promise.resolve(true);
137
+ }
138
+ else {
139
+ this.platformReady = new Promise((resolve, reject) => {
140
+ window.addEventListener("flutterInAppWebViewPlatformReady", function () {
141
+ console.log("flutter android/ios platform is ready");
142
+ resolve(true);
143
+ });
144
+ setTimeout(() => {
145
+ console.log("flutter android/ios platform is timeout");
146
+ reject("timeout");
147
+ }, 1500);
135
148
  });
136
- setTimeout(() => {
137
- reject("timeout");
138
- }, 1500);
139
- });
149
+ }
140
150
  }
141
151
  else if (this.isLocalDomain(domain)) {
142
152
  this.mode = "dev";
@@ -182,6 +192,10 @@ class Cpzxrobot {
182
192
  // @ts-ignore
183
193
  window._notifyUnitChanged = cb;
184
194
  break;
195
+ case "factoryChanged":
196
+ // @ts-ignore
197
+ window._notifyFactoryChanged = cb;
198
+ break;
185
199
  }
186
200
  }
187
201
  //打开其他小程序
@@ -26,7 +26,7 @@ class PigfarmGateway extends Object {
26
26
  });
27
27
  });
28
28
  }
29
- //获得周/月/季度统计
29
+ //获得周/月/季度统计,如果出现跨批次的情况时,传回的数据的起始时间可能不是周/月/季度的开始时间,而是本批次的开始时间
30
30
  periodReportForUnit(unit, time, type) {
31
31
  return this.context.ready.then((axios) => {
32
32
  return axios.post(`/api/v1/pigfarm/statistics/${unit.id}`, {
package/index.ts CHANGED
@@ -31,9 +31,9 @@ export class Cpzxrobot {
31
31
  _getSelectedFarmFromMiniApp!: () => any;
32
32
  _getSelectedUnitFromMiniApp!: () => any;
33
33
  _jumpToMiniApp!: (url: string) => any;
34
- setTitle!: (title: string) => void;
35
- saveBase64!: (base64: string, filename: string) => void;
36
- saveBlob!: (blob: Blob, filename: string) => void;
34
+ setTitle!: (title: string) => void;
35
+ saveBase64!: (base64: string, filename: string) => void;
36
+ saveBlob!: (blob: Blob, filename: string) => void;
37
37
  assistant: AssistantGateway;
38
38
  energy: EnergyGateway;
39
39
  camera: CameraGateway;
@@ -157,18 +157,28 @@ export class Cpzxrobot {
157
157
  return platform.callHandler("axios_post", url, data);
158
158
  },
159
159
  };
160
- this.platformReady = new Promise<boolean>((resolve, reject) => {
161
- window.addEventListener(
162
- "flutterInAppWebViewPlatformReady",
163
- function () {
164
- console.log("flutter android/ios platform is ready");
165
- resolve(true);
166
- }
167
- );
168
- setTimeout(() => {
169
- reject("timeout");
170
- }, 1500);
171
- });
160
+ if (
161
+ // @ts-ignore
162
+ window.flutter_inappwebview != null &&
163
+ // @ts-ignore
164
+ window.flutter_inappwebview.callHandler != null
165
+ ) {
166
+ this.platformReady = Promise.resolve(true);
167
+ } else {
168
+ this.platformReady = new Promise<boolean>((resolve, reject) => {
169
+ window.addEventListener(
170
+ "flutterInAppWebViewPlatformReady",
171
+ function () {
172
+ console.log("flutter android/ios platform is ready");
173
+ resolve(true);
174
+ }
175
+ );
176
+ setTimeout(() => {
177
+ console.log("flutter android/ios platform is timeout");
178
+ reject("timeout");
179
+ }, 1500);
180
+ });
181
+ }
172
182
  } else if (this.isLocalDomain(domain)) {
173
183
  this.mode = "dev";
174
184
  this.setTitle = function (title: string) {
@@ -216,6 +226,10 @@ export class Cpzxrobot {
216
226
  // @ts-ignore
217
227
  window._notifyUnitChanged = cb;
218
228
  break;
229
+ case "factoryChanged":
230
+ // @ts-ignore
231
+ window._notifyFactoryChanged = cb;
232
+ break;
219
233
  }
220
234
  }
221
235
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -29,7 +29,7 @@ export class PigfarmGateway extends Object {
29
29
  });
30
30
  }
31
31
 
32
- //获得周/月/季度统计
32
+ //获得周/月/季度统计,如果出现跨批次的情况时,传回的数据的起始时间可能不是周/月/季度的开始时间,而是本批次的开始时间
33
33
  periodReportForUnit(
34
34
  unit: Unit,
35
35
  time: "week" | "month" | "season",