@cpzxrobot/sdk 1.3.69 → 1.3.71

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.
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.WebPlatform = void 0;
4
13
  class WebPlatform {
@@ -11,7 +20,7 @@ class WebPlatform {
11
20
  this._selectedFarm = selectedFarm;
12
21
  this._selectedUnit = selectedUnit;
13
22
  }
14
- addMessage(message) {
23
+ addMessage(_message) {
15
24
  throw new Error("Method not implemented.");
16
25
  }
17
26
  getToken() {
@@ -26,64 +35,68 @@ class WebPlatform {
26
35
  setSelectedUnit(unit) {
27
36
  this._selectedUnit = unit;
28
37
  }
29
- async fetchWithAuth(input, init) {
30
- var _a;
31
- const headers = new Headers(init === null || init === void 0 ? void 0 : init.headers);
32
- headers.set('Authorization', this.token);
33
- headers.set('Miniapp-Code', (_a = this.appCode) !== null && _a !== void 0 ? _a : "");
34
- const response = await fetch(this.baseURL + input.toString(), Object.assign(Object.assign({}, init), { headers }));
35
- if (!response.ok) {
36
- throw new Error(`HTTP error! status: ${response.status}`);
37
- }
38
- return response;
38
+ fetchWithAuth(input, init) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ var _a;
41
+ const headers = new Headers(init === null || init === void 0 ? void 0 : init.headers);
42
+ headers.set('Authorization', this.token);
43
+ headers.set('Miniapp-Code', (_a = this.appCode) !== null && _a !== void 0 ? _a : "");
44
+ const response = yield fetch(this.baseURL + input.toString(), Object.assign(Object.assign({}, init), { headers }));
45
+ if (!response.ok) {
46
+ throw new Error(`HTTP error! status: ${response.status}`);
47
+ }
48
+ return response;
49
+ });
39
50
  }
40
51
  ;
41
- async streamWithAuth(input, init, fn) {
42
- var _a;
43
- const headers = new Headers(init === null || init === void 0 ? void 0 : init.headers);
44
- headers.set('Authorization', this.token);
45
- headers.set('Miniapp-Code', (_a = this.appCode) !== null && _a !== void 0 ? _a : "");
46
- headers.set('Accept', 'text/event-stream');
47
- headers.set('Cache-Control', 'no-cache');
48
- const response = await fetch(this.baseURL + input.toString(), Object.assign(Object.assign({}, init), { headers }));
49
- var reader = response.body.getReader();
50
- const decoder = new TextDecoder("utf-8");
51
- let done = false;
52
- var buf = "";
53
- while (!done) {
54
- const { value, done } = await reader.read();
55
- if (done) {
56
- break;
57
- }
58
- const chunkValue = decoder.decode(value);
59
- //split value to lines
60
- // 将值拆分为行
61
- buf = buf + chunkValue;
62
- var i = buf.indexOf("\n");
63
- while (i > -1) {
64
- //find first \n
65
- var line = buf.substring(0, i);
66
- try {
67
- if (line === "[DONE]") {
68
- break;
52
+ streamWithAuth(input, init, fn) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ var _a;
55
+ const headers = new Headers(init === null || init === void 0 ? void 0 : init.headers);
56
+ headers.set('Authorization', this.token);
57
+ headers.set('Miniapp-Code', (_a = this.appCode) !== null && _a !== void 0 ? _a : "");
58
+ headers.set('Accept', 'text/event-stream');
59
+ headers.set('Cache-Control', 'no-cache');
60
+ const response = yield fetch(this.baseURL + input.toString(), Object.assign(Object.assign({}, init), { headers }));
61
+ var reader = response.body.getReader();
62
+ const decoder = new TextDecoder("utf-8");
63
+ let done = false;
64
+ var buf = "";
65
+ while (!done) {
66
+ const { value, done } = yield reader.read();
67
+ if (done) {
68
+ break;
69
+ }
70
+ const chunkValue = decoder.decode(value);
71
+ //split value to lines
72
+ // 将值拆分为行
73
+ buf = buf + chunkValue;
74
+ var i = buf.indexOf("\n");
75
+ while (i > -1) {
76
+ //find first \n
77
+ var line = buf.substring(0, i);
78
+ try {
79
+ if (line === "[DONE]") {
80
+ break;
81
+ }
82
+ else if (line.startsWith("data: ")) {
83
+ // remove prefix 'data: '
84
+ // 移除前缀 'data: '
85
+ var data = JSON.parse(line.split(": ")[1]);
86
+ //{"choices":[{"delta":{"content":" </"},"index":0}],"created":1741749068,"id":"chatcmpl-67ccb889154043f5874cbf3a64ec163e","model":"DeepSeek-R1","object":"chat.completion.chunk"}
87
+ fn === null || fn === void 0 ? void 0 : fn(data);
88
+ }
69
89
  }
70
- else if (line.startsWith("data: ")) {
71
- // remove prefix 'data: '
72
- // 移除前缀 'data: '
73
- var data = JSON.parse(line.split(": ")[1]);
74
- //{"choices":[{"delta":{"content":" </"},"index":0}],"created":1741749068,"id":"chatcmpl-67ccb889154043f5874cbf3a64ec163e","model":"DeepSeek-R1","object":"chat.completion.chunk"}
75
- fn === null || fn === void 0 ? void 0 : fn(data);
90
+ catch (e) {
91
+ console.error("解析失败", e);
76
92
  }
93
+ buf = buf.substring(i + 1);
94
+ i = buf.indexOf("\n");
77
95
  }
78
- catch (e) {
79
- console.error("解析失败", e);
80
- }
81
- buf = buf.substring(i + 1);
82
- i = buf.indexOf("\n");
83
96
  }
84
- }
85
- ;
86
- return true;
97
+ ;
98
+ return true;
99
+ });
87
100
  }
88
101
  ;
89
102
  processQueryParams(url, config) {
@@ -115,170 +128,174 @@ class WebPlatform {
115
128
  getAxiosFromMiniApp() {
116
129
  var instance = this;
117
130
  return {
118
- get: async (url, config) => {
131
+ get: (url, config) => __awaiter(this, void 0, void 0, function* () {
119
132
  var _a;
120
133
  url = instance.processQueryParams(url, config);
121
- const response = await this.fetchWithAuth(url, {
134
+ const response = yield this.fetchWithAuth(url, {
122
135
  method: 'GET',
123
136
  headers: config === null || config === void 0 ? void 0 : config.headers
124
137
  });
125
138
  //test content-type, if it is json, then parse it
126
139
  if ((_a = response.headers.get('Content-Type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
127
- return { data: await response.json() };
140
+ return { data: yield response.json() };
128
141
  }
129
142
  else {
130
143
  return response.blob();
131
144
  }
132
- },
133
- delete: async (url, data, config) => {
134
- const response = await this.fetchWithAuth(url, {
145
+ }),
146
+ delete: (url, data, config) => __awaiter(this, void 0, void 0, function* () {
147
+ const response = yield this.fetchWithAuth(url, {
135
148
  method: 'DELETE',
136
149
  headers: Object.assign({ 'Content-Type': 'application/json' }, config === null || config === void 0 ? void 0 : config.headers),
137
150
  body: JSON.stringify(data)
138
151
  });
139
- return { data: await response.json() };
140
- },
141
- put: async (url, data, config) => {
142
- const response = await this.fetchWithAuth(url, {
152
+ return { data: yield response.json() };
153
+ }),
154
+ put: (url, data, config) => __awaiter(this, void 0, void 0, function* () {
155
+ const response = yield this.fetchWithAuth(url, {
143
156
  method: 'PUT',
144
157
  headers: Object.assign({ 'Content-Type': 'application/json' }, config === null || config === void 0 ? void 0 : config.headers),
145
158
  body: JSON.stringify(data)
146
159
  });
147
- return { data: await response.json() };
148
- },
149
- post: async (url, data, config) => {
150
- const response = await this.fetchWithAuth(url, {
160
+ return { data: yield response.json() };
161
+ }),
162
+ post: (url, data, config) => __awaiter(this, void 0, void 0, function* () {
163
+ const response = yield this.fetchWithAuth(url, {
151
164
  method: 'POST',
152
165
  headers: Object.assign({ 'Content-Type': 'application/json' }, config === null || config === void 0 ? void 0 : config.headers),
153
166
  body: JSON.stringify(data)
154
167
  });
155
- return { data: await response.json() };
156
- },
157
- getAndSave: async function (url, config) {
158
- var _a;
159
- url = instance.processQueryParams(url, config);
160
- const response = await instance.fetchWithAuth(url, {
161
- method: 'GET',
162
- headers: config === null || config === void 0 ? void 0 : config.headers
163
- });
164
- const blob = await response.blob();
165
- // 文件名解析逻辑
166
- const contentDisposition = response.headers.get('Content-Disposition');
167
- let filename = (_a = config === null || config === void 0 ? void 0 : config.fileName) !== null && _a !== void 0 ? _a : ""; // 默认文件名
168
- // 1. 优先使用响应头中的文件名
169
- if (filename == "") {
170
- if (contentDisposition) {
171
- const utf8FilenameMatch = contentDisposition.match(/filename\*=UTF-8''(.+)/i);
172
- if (utf8FilenameMatch) {
173
- filename = decodeURIComponent(utf8FilenameMatch[1]);
168
+ return { data: yield response.json() };
169
+ }),
170
+ getAndSave: function (url, config) {
171
+ return __awaiter(this, void 0, void 0, function* () {
172
+ var _a;
173
+ url = instance.processQueryParams(url, config);
174
+ const response = yield instance.fetchWithAuth(url, {
175
+ method: 'GET',
176
+ headers: config === null || config === void 0 ? void 0 : config.headers
177
+ });
178
+ const blob = yield response.blob();
179
+ // 文件名解析逻辑
180
+ const contentDisposition = response.headers.get('Content-Disposition');
181
+ let filename = (_a = config === null || config === void 0 ? void 0 : config.fileName) !== null && _a !== void 0 ? _a : ""; // 默认文件名
182
+ // 1. 优先使用响应头中的文件名
183
+ if (filename == "") {
184
+ if (contentDisposition) {
185
+ const utf8FilenameMatch = contentDisposition.match(/filename\*=UTF-8''(.+)/i);
186
+ if (utf8FilenameMatch) {
187
+ filename = decodeURIComponent(utf8FilenameMatch[1]);
188
+ }
189
+ else {
190
+ const filenameMatch = contentDisposition.match(/filename="?(.+?)"?(;|$)/i);
191
+ if (filenameMatch)
192
+ filename = filenameMatch[1];
193
+ }
174
194
  }
175
195
  else {
176
- const filenameMatch = contentDisposition.match(/filename="?(.+?)"?(;|$)/i);
177
- if (filenameMatch)
178
- filename = filenameMatch[1];
196
+ filename = "file";
179
197
  }
180
198
  }
181
- else {
182
- filename = "file";
183
- }
184
- }
185
- await instance.saveBlob(blob, filename);
186
- return { data: blob };
187
- },
188
- getAndPreview: async function (url, config) {
189
- var _a;
190
- url = instance.processQueryParams(url, config);
191
- const response = await instance.fetchWithAuth(url, {
192
- method: 'GET',
199
+ yield instance.saveBlob(blob, filename);
200
+ return { data: blob };
193
201
  });
194
- const blob = await response.blob();
195
- const contentType = response.headers.get('Content-Type') || '';
196
- // 解析文件名
197
- const contentDisposition = response.headers.get('Content-Disposition');
198
- let filename = (_a = config === null || config === void 0 ? void 0 : config.fileName) !== null && _a !== void 0 ? _a : "";
199
- if (filename === "") {
200
- if (contentDisposition) {
201
- const utf8FilenameMatch = contentDisposition.match(/filename\*=UTF-8''(.+)/i);
202
- if (utf8FilenameMatch) {
203
- filename = decodeURIComponent(utf8FilenameMatch[1]);
202
+ },
203
+ getAndPreview: function (url, config) {
204
+ return __awaiter(this, void 0, void 0, function* () {
205
+ var _a;
206
+ url = instance.processQueryParams(url, config);
207
+ const response = yield instance.fetchWithAuth(url, {
208
+ method: 'GET',
209
+ });
210
+ const blob = yield response.blob();
211
+ const contentType = response.headers.get('Content-Type') || '';
212
+ // 解析文件名
213
+ const contentDisposition = response.headers.get('Content-Disposition');
214
+ let filename = (_a = config === null || config === void 0 ? void 0 : config.fileName) !== null && _a !== void 0 ? _a : "";
215
+ if (filename === "") {
216
+ if (contentDisposition) {
217
+ const utf8FilenameMatch = contentDisposition.match(/filename\*=UTF-8''(.+)/i);
218
+ if (utf8FilenameMatch) {
219
+ filename = decodeURIComponent(utf8FilenameMatch[1]);
220
+ }
221
+ else {
222
+ const filenameMatch = contentDisposition.match(/filename="?(.+?)"?(;|$)/i);
223
+ if (filenameMatch)
224
+ filename = filenameMatch[1];
225
+ }
204
226
  }
205
227
  else {
206
- const filenameMatch = contentDisposition.match(/filename="?(.+?)"?(;|$)/i);
207
- if (filenameMatch)
208
- filename = filenameMatch[1];
228
+ filename = "file";
209
229
  }
210
230
  }
211
- else {
212
- filename = "file";
213
- }
214
- }
215
- // 支持预览的文件类型
216
- const previewableTypes = [
217
- 'image/jpeg', 'image/png', 'image/gif', 'image/svg+xml',
218
- 'application/pdf',
219
- 'text/plain', 'application/json', 'text/csv', 'text/xml',
220
- 'video/mp4', 'audio/mpeg'
221
- ];
222
- if (previewableTypes.some(type => contentType.includes(type))) {
223
- const previewUrl = URL.createObjectURL(blob);
224
- if (contentType.includes('image')) {
225
- // 图片预览 - 直接在新窗口打开 blob URL
226
- const win = window.open(previewUrl, '_blank');
227
- if (win) {
228
- win.document.title = filename;
229
- win.addEventListener('beforeunload', () => URL.revokeObjectURL(previewUrl));
231
+ // 支持预览的文件类型
232
+ const previewableTypes = [
233
+ 'image/jpeg', 'image/png', 'image/gif', 'image/svg+xml',
234
+ 'application/pdf',
235
+ 'text/plain', 'application/json', 'text/csv', 'text/xml',
236
+ 'video/mp4', 'audio/mpeg'
237
+ ];
238
+ if (previewableTypes.some(type => contentType.includes(type))) {
239
+ const previewUrl = URL.createObjectURL(blob);
240
+ if (contentType.includes('image')) {
241
+ // 图片预览 - 直接在新窗口打开 blob URL
242
+ const win = window.open(previewUrl, '_blank');
243
+ if (win) {
244
+ win.document.title = filename;
245
+ win.addEventListener('beforeunload', () => URL.revokeObjectURL(previewUrl));
246
+ }
247
+ return { data: blob };
230
248
  }
231
- return { data: blob };
232
- }
233
- else if (contentType.includes('pdf')) {
234
- // PDF预览 - 直接在新窗口打开 blob URL
235
- const win = window.open(previewUrl, '_blank');
236
- if (win) {
237
- win.document.title = filename;
238
- win.addEventListener('beforeunload', () => URL.revokeObjectURL(previewUrl));
249
+ else if (contentType.includes('pdf')) {
250
+ // PDF预览 - 直接在新窗口打开 blob URL
251
+ const win = window.open(previewUrl, '_blank');
252
+ if (win) {
253
+ win.document.title = filename;
254
+ win.addEventListener('beforeunload', () => URL.revokeObjectURL(previewUrl));
255
+ }
256
+ return { data: blob };
239
257
  }
240
- return { data: blob };
241
- }
242
- else if (contentType.includes('text') || contentType.includes('json') || contentType.includes('xml') || contentType.includes('csv')) {
243
- // 文本文件预览 - 创建下载链接并自动点击
244
- const text = await blob.text();
245
- const blobObj = new Blob([text], { type: contentType });
246
- const url = URL.createObjectURL(blobObj);
247
- const a = document.createElement('a');
248
- a.href = url;
249
- a.target = '_blank';
250
- a.style.display = 'none';
251
- document.body.appendChild(a);
252
- a.click();
253
- setTimeout(() => {
254
- document.body.removeChild(a);
255
- URL.revokeObjectURL(url);
256
- }, 100);
257
- return { data: blob };
258
- }
259
- else if (contentType.includes('video') || contentType.includes('audio')) {
260
- // 视频/音频预览 - 直接在新窗口打开 blob URL
261
- const win = window.open(previewUrl, '_blank');
262
- if (win) {
263
- win.document.title = filename;
264
- win.addEventListener('beforeunload', () => URL.revokeObjectURL(previewUrl));
258
+ else if (contentType.includes('text') || contentType.includes('json') || contentType.includes('xml') || contentType.includes('csv')) {
259
+ // 文本文件预览 - 创建下载链接并自动点击
260
+ const text = yield blob.text();
261
+ const blobObj = new Blob([text], { type: contentType });
262
+ const url = URL.createObjectURL(blobObj);
263
+ const a = document.createElement('a');
264
+ a.href = url;
265
+ a.target = '_blank';
266
+ a.style.display = 'none';
267
+ document.body.appendChild(a);
268
+ a.click();
269
+ setTimeout(() => {
270
+ document.body.removeChild(a);
271
+ URL.revokeObjectURL(url);
272
+ }, 100);
273
+ return { data: blob };
274
+ }
275
+ else if (contentType.includes('video') || contentType.includes('audio')) {
276
+ // 视频/音频预览 - 直接在新窗口打开 blob URL
277
+ const win = window.open(previewUrl, '_blank');
278
+ if (win) {
279
+ win.document.title = filename;
280
+ win.addEventListener('beforeunload', () => URL.revokeObjectURL(previewUrl));
281
+ }
282
+ return { data: blob };
265
283
  }
266
- return { data: blob };
267
284
  }
268
- }
269
- // 不支持的预览类型或preview=false时,直接下载
270
- await instance.saveBlob(blob, filename);
271
- return { data: blob };
285
+ // 不支持的预览类型或preview=false时,直接下载
286
+ yield instance.saveBlob(blob, filename);
287
+ return { data: blob };
288
+ });
272
289
  },
273
- upload: async (url, option) => {
274
- return new Promise((resolve, reject) => {
290
+ upload: (url, option) => __awaiter(this, void 0, void 0, function* () {
291
+ return new Promise((resolve, _reject) => {
275
292
  const button = document.createElement("input");
276
293
  button.type = "file";
277
294
  button.style.display = "none";
278
295
  button.multiple = (option === null || option === void 0 ? void 0 : option.multiple) || false;
279
296
  document.body.appendChild(button);
280
297
  button.click(); // 手动触发点击
281
- button.onchange = async (e) => {
298
+ button.onchange = (e) => __awaiter(this, void 0, void 0, function* () {
282
299
  const files = e.target.files;
283
300
  if (files && files.length > 0) {
284
301
  const formData = new FormData();
@@ -293,21 +310,21 @@ class WebPlatform {
293
310
  for (let key in option === null || option === void 0 ? void 0 : option["data"]) {
294
311
  formData.append(key, option["data"][key]);
295
312
  }
296
- const response = await instance.fetchWithAuth(url, {
313
+ const response = yield instance.fetchWithAuth(url, {
297
314
  method: 'POST',
298
315
  body: formData
299
316
  });
300
317
  button.remove();
301
- resolve({ data: await response.json() });
318
+ resolve({ data: yield response.json() });
302
319
  }
303
320
  else {
304
321
  button.remove();
305
322
  resolve({ data: { Error: "没有选择文件" } });
306
323
  }
307
- };
324
+ });
308
325
  });
309
- },
310
- getAsSse: (url, fn, config) => {
326
+ }),
327
+ getAsSse: (url, fn, _config) => {
311
328
  return new Promise((resolve, reject) => {
312
329
  instance.streamWithAuth(url, {
313
330
  method: 'GET',
@@ -335,17 +352,19 @@ class WebPlatform {
335
352
  setTitle(title) {
336
353
  document.title = title;
337
354
  }
338
- async saveBase64(base64, filename) {
339
- const byteCharacters = atob(base64);
340
- const byteNumbers = new Array(byteCharacters.length);
341
- for (let i = 0; i < byteCharacters.length; i++) {
342
- byteNumbers[i] = byteCharacters.charCodeAt(i);
343
- }
344
- const byteArray = new Uint8Array(byteNumbers);
345
- const blob = new Blob([byteArray], {
346
- type: "application/octet-stream",
355
+ saveBase64(base64, filename) {
356
+ return __awaiter(this, void 0, void 0, function* () {
357
+ const byteCharacters = atob(base64);
358
+ const byteNumbers = new Array(byteCharacters.length);
359
+ for (let i = 0; i < byteCharacters.length; i++) {
360
+ byteNumbers[i] = byteCharacters.charCodeAt(i);
361
+ }
362
+ const byteArray = new Uint8Array(byteNumbers);
363
+ const blob = new Blob([byteArray], {
364
+ type: "application/octet-stream",
365
+ });
366
+ return this.saveBlob(blob, filename);
347
367
  });
348
- return this.saveBlob(blob, filename);
349
368
  }
350
369
  saveBlob(blob, filename) {
351
370
  return new Promise((resolve, reject) => {
@@ -372,10 +391,10 @@ class WebPlatform {
372
391
  navigator.vibrate(time || 200);
373
392
  }
374
393
  }
375
- showInDeviceManager(deviceId, type) {
394
+ showInDeviceManager(_deviceId, _type) {
376
395
  return Promise.resolve();
377
396
  }
378
- reloadGroup(key) {
397
+ reloadGroup(_key) {
379
398
  // No implementation in web platform
380
399
  }
381
400
  getGeo() {
@@ -395,16 +414,16 @@ class WebPlatform {
395
414
  }
396
415
  });
397
416
  }
398
- setResult(name, value) {
417
+ setResult(_name, _value) {
399
418
  // No implementation in web platform
400
419
  }
401
- setResultAs(name, value, type) {
420
+ setResultAs(_name, _value, _type) {
402
421
  // No implementation in web platform
403
422
  }
404
423
  setError(message) {
405
424
  console.error(message);
406
425
  }
407
- setProgress(precentage) {
426
+ setProgress(_precentage) {
408
427
  // No implementation in web platform
409
428
  }
410
429
  }
@@ -1,8 +1,18 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.WindwosMiniAppPlatform = void 0;
4
13
  class WindwosMiniAppPlatform {
5
14
  constructor() {
15
+ // private messagePort?: MessagePort;
6
16
  this.sseCallbacks = {};
7
17
  this.token = "";
8
18
  this.appCode = "";
@@ -17,9 +27,9 @@ class WindwosMiniAppPlatform {
17
27
  getToken() {
18
28
  return "";
19
29
  }
20
- setToken(token) {
30
+ setToken(_token) {
21
31
  }
22
- setSelectedFarm(farm) {
32
+ setSelectedFarm(_farm) {
23
33
  throw new Error("Method not implemented.");
24
34
  }
25
35
  setSelectedUnit(unit) {
@@ -72,11 +82,11 @@ class WindwosMiniAppPlatform {
72
82
  const reader = new FileReader();
73
83
  return new Promise((resolve, reject) => {
74
84
  reader.readAsDataURL(blob);
75
- reader.onloadend = async () => {
85
+ reader.onloadend = () => __awaiter(this, void 0, void 0, function* () {
76
86
  const base64 = reader.result;
77
- await this.saveBase64(base64, filename);
87
+ yield this.saveBase64(base64, filename);
78
88
  resolve();
79
- };
89
+ });
80
90
  reader.onerror = (err) => {
81
91
  reject(err);
82
92
  };
@@ -24,7 +24,7 @@ export class FactoryGateway extends Object {
24
24
  //获得工厂的单元信息
25
25
  async unit(id: number): Promise<any> {
26
26
  var axios = await this.context.ready;
27
- const response = await axios.get(`/api/v1/workshop/unit/${id}`);
27
+ const response = await axios.get(`/api/v1/unit/${id}`);
28
28
  return response.data;
29
29
  }
30
30
 
@@ -154,7 +154,7 @@ export class FactoryGateway extends Object {
154
154
  //支持以下三个name:'capacity'(规模),'used_capacity'(存栏量),'workshop_count'(栋舍/车间数量),'manager'(负责人),'electric'/'water'/'feed' (电耗/水耗/饲料耗)
155
155
  async entry(factory: Factory, name: string): Promise<any> {
156
156
  var axios = await this.context.ready;
157
- if (["electric", "water", "feed"].includes(name)) {
157
+ if (["electric", "water", "feed"].indexOf(name) !== -1) {
158
158
  const response = await axios.post(
159
159
  `/api/v1/pigfarm/consumption/${factory.id}`,
160
160
  {
package/index.ts CHANGED
@@ -8,7 +8,7 @@ import { AssistantGateway } from "./assistant_gateway";
8
8
  import { EnergyGateway } from "./energy_gateway";
9
9
  import { CameraGateway } from "./camera_gateway";
10
10
  import { PigfarmGateway } from "./pigfarm_gateway";
11
- import { Device, Factory, MyAxiosInstance, Unit } from "./types";
11
+ import { Factory, MyAxiosInstance, Unit } from "./types";
12
12
  import { UnitGateway } from "./unit_gateway";
13
13
  import { ChickenFarmGateway } from "./chickenfarm_gateway";
14
14
  import { CarGateway } from "./car_gateway";
@@ -324,7 +324,7 @@ export class Cpzxrobot {
324
324
  const localDomains = ["localhost", "127.0.0.1", "0.0.0.0"];
325
325
 
326
326
  // 检查当前域名是否在本地开发域名列表中
327
- return localDomains.includes(domain);
327
+ return localDomains.indexOf(domain) !== -1;
328
328
  }
329
329
 
330
330
  setTitle(title: string) {
@@ -335,7 +335,7 @@ export class Cpzxrobot {
335
335
  }
336
336
  }
337
337
 
338
- addMessage(message: any){
338
+ addMessage(message: any) {
339
339
  if (this.platform) {
340
340
  this.platform.addMessage(message);
341
341
  } else {