@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.
- package/dist/web_platform.js +3 -2
- package/package.json +1 -1
- package/web_platform.ts +3 -2
package/dist/web_platform.js
CHANGED
|
@@ -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
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
|
};
|