@jetlinks-web/core 2.2.8 → 2.2.9
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/package.json +2 -2
- package/src/fetch.ts +6 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jetlinks-web/core",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.9",
|
|
4
4
|
"main": "index.ts",
|
|
5
5
|
"module": "index.ts",
|
|
6
6
|
"keywords": [
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"axios": "^1.7.4",
|
|
23
23
|
"rxjs": "^7.8.1",
|
|
24
|
-
"@jetlinks-web/types": "^1.0.2",
|
|
25
24
|
"@jetlinks-web/constants": "^1.0.9",
|
|
25
|
+
"@jetlinks-web/types": "^1.0.2",
|
|
26
26
|
"@jetlinks-web/utils": "^1.2.8"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
package/src/fetch.ts
CHANGED
|
@@ -3,14 +3,13 @@ import {BASE_API, TOKEN_KEY} from "@jetlinks-web/constants";
|
|
|
3
3
|
import {isFunction, isObject} from "lodash-es";
|
|
4
4
|
import { Observable, } from 'rxjs'
|
|
5
5
|
|
|
6
|
-
const controller = new AbortController();
|
|
7
|
-
|
|
8
6
|
export class NdJson {
|
|
9
7
|
options: any = {
|
|
10
8
|
code: 200,
|
|
11
9
|
codeKey: 'status'
|
|
12
10
|
}
|
|
13
11
|
isRead = false
|
|
12
|
+
controller = null
|
|
14
13
|
constructor() {}
|
|
15
14
|
|
|
16
15
|
create(options) {
|
|
@@ -24,6 +23,8 @@ export class NdJson {
|
|
|
24
23
|
get(url, data = '{}', extra = {}) {
|
|
25
24
|
const _url = this.getUrl(url)
|
|
26
25
|
const that = this
|
|
26
|
+
const controller = this.controller = new AbortController();
|
|
27
|
+
|
|
27
28
|
return new Observable(observer => {
|
|
28
29
|
let reader
|
|
29
30
|
fetch(
|
|
@@ -101,6 +102,7 @@ export class NdJson {
|
|
|
101
102
|
post(url, data={}, extra = {}) {
|
|
102
103
|
const _url = this.getUrl(url)
|
|
103
104
|
const that = this
|
|
105
|
+
const controller = this.controller = new AbortController();
|
|
104
106
|
|
|
105
107
|
return new Observable(observer => {
|
|
106
108
|
let reader
|
|
@@ -222,7 +224,8 @@ export class NdJson {
|
|
|
222
224
|
if (this.isRead) {
|
|
223
225
|
this.isRead = false
|
|
224
226
|
}
|
|
225
|
-
|
|
227
|
+
|
|
228
|
+
this.controller.abort()
|
|
226
229
|
}
|
|
227
230
|
}
|
|
228
231
|
|