@cpzxrobot/sdk 1.3.6 → 1.3.8

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.
@@ -41,6 +41,7 @@ class WebPlatform {
41
41
  headers.set('Authorization', this.token);
42
42
  headers.set('Miniapp-Code', (_a = this.appCode) !== null && _a !== void 0 ? _a : "");
43
43
  headers.set('Accept', 'text/event-stream');
44
+ headers.set('Cache-Control', 'no-cache');
44
45
  const response = await fetch(this.baseURL + input.toString(), Object.assign(Object.assign({}, init), { headers }));
45
46
  var reader = response.body.getReader();
46
47
  const decoder = new TextDecoder("utf-8");
@@ -63,7 +64,7 @@ class WebPlatform {
63
64
  if (line === "[DONE]") {
64
65
  break;
65
66
  }
66
- else {
67
+ else if (line.startsWith("data: ")) {
67
68
  // remove prefix 'data: '
68
69
  // 移除前缀 'data: '
69
70
  var data = JSON.parse(line.split(": ")[1]);
@@ -199,7 +200,7 @@ class WebPlatform {
199
200
  return new Promise((resolve, reject) => {
200
201
  instance.streamWithAuth(url, {
201
202
  method: 'GET',
202
- }, fn);
203
+ }, fn).then(resolve).catch(reject);
203
204
  });
204
205
  }
205
206
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/web_platform.ts CHANGED
@@ -47,6 +47,7 @@ export class WebPlatform implements PlatformInterface {
47
47
  headers.set('Authorization', this.token);
48
48
  headers.set('Miniapp-Code', this.appCode ?? "");
49
49
  headers.set('Accept', 'text/event-stream');
50
+ headers.set('Cache-Control', 'no-cache');
50
51
  const response = await fetch(this.baseURL + input.toString(), {
51
52
  ...init,
52
53
  headers
@@ -73,7 +74,7 @@ export class WebPlatform implements PlatformInterface {
73
74
  try {
74
75
  if (line === "[DONE]") {
75
76
  break;
76
- } else {
77
+ } else if (line.startsWith("data: ")) {
77
78
  // remove prefix 'data: '
78
79
  // 移除前缀 'data: '
79
80
  var data = JSON.parse(line.split(": ")[1]);
@@ -214,7 +215,7 @@ export class WebPlatform implements PlatformInterface {
214
215
  return new Promise<any>((resolve, reject) => {
215
216
  instance.streamWithAuth(url, {
216
217
  method: 'GET',
217
- }, fn);
218
+ }, fn).then(resolve).catch(reject);
218
219
  });
219
220
  }
220
221
  };