@10yun/cv-mobile-ui 0.5.37 → 0.5.38
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/README.md +1 -1
- package/package.json +2 -2
- package/plugins/luch-request/utils/clone.js +28 -32
- package/ui-cv/components/cv-code-sms/cv-code-sms.vue +9 -0
- package/uview-plus/libs/luch-request/adapters/index.js +113 -79
- package/uview-plus/libs/luch-request/core/InterceptorManager.js +19 -19
- package/uview-plus/libs/luch-request/core/Request.js +146 -146
- package/uview-plus/libs/luch-request/core/buildFullPath.js +7 -7
- package/uview-plus/libs/luch-request/core/defaults.js +27 -24
- package/uview-plus/libs/luch-request/core/dispatchRequest.js +4 -2
- package/uview-plus/libs/luch-request/core/mergeConfig.js +106 -84
- package/uview-plus/libs/luch-request/core/settle.js +7 -7
- package/uview-plus/libs/luch-request/helpers/buildURL.js +50 -48
- package/uview-plus/libs/luch-request/helpers/combineURLs.js +2 -4
- package/uview-plus/libs/luch-request/helpers/isAbsoluteURL.js +5 -5
- package/uview-plus/libs/luch-request/index.d.ts +184 -103
- package/uview-plus/libs/luch-request/index.js +2 -3
- package/uview-plus/libs/luch-request/readme.md +3 -0
- package/uview-plus/libs/luch-request/utils/clone.js +28 -32
- package/uview-plus/libs/luch-request/utils.js +41 -41
- package/plugins/request.js +0 -571
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @Class Request
|
|
3
3
|
* @description luch-request http请求插件
|
|
4
|
-
* @version 3.0.7
|
|
5
4
|
* @Author lu-ch
|
|
6
|
-
* @Date 2021-09-04
|
|
7
5
|
* @Email webwork.s@qq.com
|
|
8
6
|
* 文档: https://www.quanzhan.co/luch-request/
|
|
9
7
|
* github: https://github.com/lei-mu/luch-request
|
|
10
8
|
* DCloud: http://ext.dcloud.net.cn/plugin?id=392
|
|
11
|
-
* HBuilderX: beat-3.0.4 alpha-3.0.4
|
|
12
9
|
*/
|
|
13
10
|
|
|
14
|
-
import dispatchRequest from './dispatchRequest'
|
|
15
|
-
import InterceptorManager from './InterceptorManager'
|
|
16
|
-
import mergeConfig from './mergeConfig'
|
|
17
|
-
import defaults from './defaults'
|
|
18
|
-
import { isPlainObject } from '../utils'
|
|
19
|
-
import clone from '../utils/clone'
|
|
11
|
+
import dispatchRequest from './dispatchRequest';
|
|
12
|
+
import InterceptorManager from './InterceptorManager';
|
|
13
|
+
import mergeConfig from './mergeConfig';
|
|
14
|
+
import defaults from './defaults';
|
|
15
|
+
import { isPlainObject } from '../utils';
|
|
16
|
+
import clone from '../utils/clone';
|
|
20
17
|
|
|
21
18
|
export default class Request {
|
|
22
|
-
|
|
19
|
+
/**
|
|
23
20
|
* @param {Object} arg - 全局配置
|
|
24
21
|
* @param {String} arg.baseURL - 全局根路径
|
|
25
22
|
* @param {Object} arg.header - 全局header
|
|
@@ -33,48 +30,47 @@ export default class Request {
|
|
|
33
30
|
* @param {Boolean} arg.firstIpv4 - 全DNS解析时优先使用ipv4。默认false。仅 App-Android 支持 (HBuilderX 2.8.0+)
|
|
34
31
|
* @param {Function(statusCode):Boolean} arg.validateStatus - 全局默认的自定义验证器。默认statusCode >= 200 && statusCode < 300
|
|
35
32
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
console.warn('设置全局参数必须接收一个Object')
|
|
41
|
-
}
|
|
42
|
-
this.config = clone({ ...defaults, ...arg })
|
|
43
|
-
this.interceptors = {
|
|
44
|
-
request: new InterceptorManager(),
|
|
45
|
-
response: new InterceptorManager()
|
|
46
|
-
}
|
|
33
|
+
constructor(arg = {}) {
|
|
34
|
+
if (!isPlainObject(arg)) {
|
|
35
|
+
arg = {};
|
|
36
|
+
console.warn('设置全局参数必须接收一个Object');
|
|
47
37
|
}
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
this.config = clone({ ...defaults, ...arg });
|
|
39
|
+
this.interceptors = {
|
|
40
|
+
request: new InterceptorManager(),
|
|
41
|
+
response: new InterceptorManager()
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
50
46
|
* @Function
|
|
51
47
|
* @param {Request~setConfigCallback} f - 设置全局默认配置
|
|
52
48
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
setConfig(f) {
|
|
50
|
+
this.config = f(this.config);
|
|
51
|
+
}
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
middleware(config) {
|
|
54
|
+
config = mergeConfig(this.config, config);
|
|
55
|
+
let chain = [dispatchRequest, undefined];
|
|
56
|
+
let promise = Promise.resolve(config);
|
|
61
57
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
59
|
+
chain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
60
|
+
});
|
|
65
61
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
|
63
|
+
chain.push(interceptor.fulfilled, interceptor.rejected);
|
|
64
|
+
});
|
|
69
65
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return promise
|
|
66
|
+
while (chain.length) {
|
|
67
|
+
promise = promise.then(chain.shift(), chain.shift());
|
|
75
68
|
}
|
|
76
69
|
|
|
77
|
-
|
|
70
|
+
return promise;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
78
74
|
* @Function
|
|
79
75
|
* @param {Object} config - 请求配置项
|
|
80
76
|
* @prop {String} options.url - 请求路径
|
|
@@ -85,110 +81,114 @@ export default class Request {
|
|
|
85
81
|
* @prop {Object} [options.method = config.method] - 请求方法
|
|
86
82
|
* @returns {Promise<unknown>}
|
|
87
83
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
84
|
+
request(config = {}) {
|
|
85
|
+
return this.middleware(config);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get(url, options = {}) {
|
|
89
|
+
return this.middleware({
|
|
90
|
+
url,
|
|
91
|
+
method: 'GET',
|
|
92
|
+
...options
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
post(url, data, options = {}) {
|
|
97
|
+
return this.middleware({
|
|
98
|
+
url,
|
|
99
|
+
data,
|
|
100
|
+
method: 'POST',
|
|
101
|
+
...options
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// #ifndef MP-ALIPAY || MP-KUAISHOU || MP-JD
|
|
106
|
+
put(url, data, options = {}) {
|
|
107
|
+
return this.middleware({
|
|
108
|
+
url,
|
|
109
|
+
data,
|
|
110
|
+
method: 'PUT',
|
|
111
|
+
...options
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// #endif
|
|
116
|
+
|
|
117
|
+
// #ifdef APP-PLUS || H5 || MP-WEIXIN || MP-BAIDU
|
|
118
|
+
delete(url, data, options = {}) {
|
|
119
|
+
return this.middleware({
|
|
120
|
+
url,
|
|
121
|
+
data,
|
|
122
|
+
method: 'DELETE',
|
|
123
|
+
...options
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// #endif
|
|
128
|
+
|
|
129
|
+
// #ifdef H5 || MP-WEIXIN
|
|
130
|
+
connect(url, data, options = {}) {
|
|
131
|
+
return this.middleware({
|
|
132
|
+
url,
|
|
133
|
+
data,
|
|
134
|
+
method: 'CONNECT',
|
|
135
|
+
...options
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// #endif
|
|
140
|
+
|
|
141
|
+
// #ifdef H5 || MP-WEIXIN || MP-BAIDU
|
|
142
|
+
head(url, data, options = {}) {
|
|
143
|
+
return this.middleware({
|
|
144
|
+
url,
|
|
145
|
+
data,
|
|
146
|
+
method: 'HEAD',
|
|
147
|
+
...options
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// #endif
|
|
152
|
+
|
|
153
|
+
// #ifdef APP-PLUS || H5 || MP-WEIXIN || MP-BAIDU
|
|
154
|
+
options(url, data, options = {}) {
|
|
155
|
+
return this.middleware({
|
|
156
|
+
url,
|
|
157
|
+
data,
|
|
158
|
+
method: 'OPTIONS',
|
|
159
|
+
...options
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// #endif
|
|
164
|
+
|
|
165
|
+
// #ifdef H5 || MP-WEIXIN
|
|
166
|
+
trace(url, data, options = {}) {
|
|
167
|
+
return this.middleware({
|
|
168
|
+
url,
|
|
169
|
+
data,
|
|
170
|
+
method: 'TRACE',
|
|
171
|
+
...options
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// #endif
|
|
176
|
+
|
|
177
|
+
upload(url, config = {}) {
|
|
178
|
+
config.url = url;
|
|
179
|
+
config.method = 'UPLOAD';
|
|
180
|
+
return this.middleware(config);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
download(url, config = {}) {
|
|
184
|
+
config.url = url;
|
|
185
|
+
config.method = 'DOWNLOAD';
|
|
186
|
+
return this.middleware(config);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
get version() {
|
|
190
|
+
return '3.1.0';
|
|
191
|
+
}
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
'use strict'
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
import isAbsoluteURL from '../helpers/isAbsoluteURL'
|
|
4
|
-
import combineURLs from '../helpers/combineURLs'
|
|
3
|
+
import isAbsoluteURL from '../helpers/isAbsoluteURL';
|
|
4
|
+
import combineURLs from '../helpers/combineURLs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Creates a new URL by combining the baseURL with the requestedURL,
|
|
@@ -13,8 +13,8 @@ import combineURLs from '../helpers/combineURLs'
|
|
|
13
13
|
* @returns {string} The combined full path
|
|
14
14
|
*/
|
|
15
15
|
export default function buildFullPath(baseURL, requestedURL) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
|
17
|
+
return combineURLs(baseURL, requestedURL);
|
|
18
|
+
}
|
|
19
|
+
return requestedURL;
|
|
20
20
|
}
|
|
@@ -3,27 +3,30 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
6
|
+
baseURL: '',
|
|
7
|
+
header: {},
|
|
8
|
+
method: 'GET',
|
|
9
|
+
dataType: 'json',
|
|
10
|
+
paramsSerializer: null,
|
|
11
|
+
// #ifndef MP-ALIPAY
|
|
12
|
+
responseType: 'text',
|
|
13
|
+
// #endif
|
|
14
|
+
custom: {},
|
|
15
|
+
// #ifdef H5 || APP-PLUS || MP-WEIXIN || MP-ALIPAY || MP-TOUTIAO || MP-KUAISHOU
|
|
16
|
+
timeout: 60000,
|
|
17
|
+
// #endif
|
|
18
|
+
// #ifdef APP-PLUS
|
|
19
|
+
sslVerify: true,
|
|
20
|
+
// #endif
|
|
21
|
+
// #ifdef H5
|
|
22
|
+
withCredentials: false,
|
|
23
|
+
// #endif
|
|
24
|
+
// #ifdef APP-PLUS
|
|
25
|
+
firstIpv4: false,
|
|
26
|
+
// #endif
|
|
27
|
+
validateStatus: function validateStatus(status) {
|
|
28
|
+
return status >= 200 && status < 300;
|
|
29
|
+
},
|
|
30
|
+
// 是否尝试将响应数据json化
|
|
31
|
+
forcedJSONParsing: true
|
|
32
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { deepMerge, isUndefined } from '../utils'
|
|
1
|
+
import { deepMerge, isUndefined } from '../utils';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 合并局部配置优先的配置,如果局部有该配置项则用局部,如果全局有该配置项则用全局
|
|
@@ -8,16 +8,16 @@ import { deepMerge, isUndefined } from '../utils'
|
|
|
8
8
|
* @return {{}}
|
|
9
9
|
*/
|
|
10
10
|
const mergeKeys = (keys, globalsConfig, config2) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
11
|
+
let config = {};
|
|
12
|
+
keys.forEach((prop) => {
|
|
13
|
+
if (!isUndefined(config2[prop])) {
|
|
14
|
+
config[prop] = config2[prop];
|
|
15
|
+
} else if (!isUndefined(globalsConfig[prop])) {
|
|
16
|
+
config[prop] = globalsConfig[prop];
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return config;
|
|
20
|
+
};
|
|
21
21
|
/**
|
|
22
22
|
*
|
|
23
23
|
* @param globalsConfig - 当前实例的全局配置
|
|
@@ -25,79 +25,101 @@ const mergeKeys = (keys, globalsConfig, config2) => {
|
|
|
25
25
|
* @return - 合并后的配置
|
|
26
26
|
*/
|
|
27
27
|
export default (globalsConfig, config2 = {}) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
const method = config2.method || globalsConfig.method || 'GET';
|
|
29
|
+
let config = {
|
|
30
|
+
baseURL: config2.baseURL || globalsConfig.baseURL || '',
|
|
31
|
+
method: method,
|
|
32
|
+
url: config2.url || '',
|
|
33
|
+
params: config2.params || {},
|
|
34
|
+
custom: { ...(globalsConfig.custom || {}), ...(config2.custom || {}) },
|
|
35
|
+
header: deepMerge(globalsConfig.header || {}, config2.header || {})
|
|
36
|
+
};
|
|
37
|
+
const defaultToConfig2Keys = ['getTask', 'validateStatus', 'paramsSerializer', 'forcedJSONParsing'];
|
|
38
|
+
config = { ...config, ...mergeKeys(defaultToConfig2Keys, globalsConfig, config2) };
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
} else {
|
|
80
|
-
const defaultsKeys = [
|
|
81
|
-
'data',
|
|
82
|
-
// #ifdef H5 || APP-PLUS || MP-ALIPAY || MP-WEIXIN
|
|
83
|
-
'timeout',
|
|
84
|
-
// #endif
|
|
85
|
-
'dataType',
|
|
86
|
-
// #ifndef MP-ALIPAY
|
|
87
|
-
'responseType',
|
|
88
|
-
// #endif
|
|
89
|
-
// #ifdef APP-PLUS
|
|
90
|
-
'sslVerify',
|
|
91
|
-
// #endif
|
|
92
|
-
// #ifdef H5
|
|
93
|
-
'withCredentials',
|
|
94
|
-
// #endif
|
|
95
|
-
// #ifdef APP-PLUS
|
|
96
|
-
'firstIpv4'
|
|
97
|
-
// #endif
|
|
98
|
-
]
|
|
99
|
-
config = { ...config, ...mergeKeys(defaultsKeys, globalsConfig, config2) }
|
|
40
|
+
// eslint-disable-next-line no-empty
|
|
41
|
+
if (method === 'DOWNLOAD') {
|
|
42
|
+
const downloadKeys = [
|
|
43
|
+
// #ifdef H5 || APP-PLUS || MP-WEIXIN || MP-ALIPAY || MP-TOUTIAO || MP-KUAISHOU
|
|
44
|
+
'timeout',
|
|
45
|
+
// #endif
|
|
46
|
+
// #ifdef MP
|
|
47
|
+
'filePath'
|
|
48
|
+
// #endif
|
|
49
|
+
];
|
|
50
|
+
config = { ...config, ...mergeKeys(downloadKeys, globalsConfig, config2) };
|
|
51
|
+
} else if (method === 'UPLOAD') {
|
|
52
|
+
delete config.header['content-type'];
|
|
53
|
+
delete config.header['Content-Type'];
|
|
54
|
+
const uploadKeys = [
|
|
55
|
+
// #ifdef APP-PLUS || H5
|
|
56
|
+
'files',
|
|
57
|
+
// #endif
|
|
58
|
+
// #ifdef MP-ALIPAY
|
|
59
|
+
'fileType',
|
|
60
|
+
// #endif
|
|
61
|
+
// #ifdef H5
|
|
62
|
+
'file',
|
|
63
|
+
// #endif
|
|
64
|
+
'filePath',
|
|
65
|
+
'name',
|
|
66
|
+
// #ifdef H5 || APP-PLUS || MP-WEIXIN || MP-ALIPAY || MP-TOUTIAO || MP-KUAISHOU
|
|
67
|
+
'timeout',
|
|
68
|
+
// #endif
|
|
69
|
+
'formData'
|
|
70
|
+
];
|
|
71
|
+
uploadKeys.forEach((prop) => {
|
|
72
|
+
if (!isUndefined(config2[prop])) {
|
|
73
|
+
config[prop] = config2[prop];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
// #ifdef H5 || APP-PLUS || MP-WEIXIN || MP-ALIPAY || MP-TOUTIAO || MP-KUAISHOU
|
|
77
|
+
if (isUndefined(config.timeout) && !isUndefined(globalsConfig.timeout)) {
|
|
78
|
+
config['timeout'] = globalsConfig['timeout'];
|
|
100
79
|
}
|
|
80
|
+
// #endif
|
|
81
|
+
} else {
|
|
82
|
+
const defaultsKeys = [
|
|
83
|
+
'data',
|
|
84
|
+
// #ifdef H5 || APP-PLUS || MP-ALIPAY || MP-WEIXIN
|
|
85
|
+
'timeout',
|
|
86
|
+
// #endif
|
|
87
|
+
'dataType',
|
|
88
|
+
// #ifndef MP-ALIPAY
|
|
89
|
+
'responseType',
|
|
90
|
+
// #endif
|
|
91
|
+
// #ifdef APP-PLUS
|
|
92
|
+
'sslVerify',
|
|
93
|
+
// #endif
|
|
94
|
+
// #ifdef H5
|
|
95
|
+
'withCredentials',
|
|
96
|
+
// #endif
|
|
97
|
+
// #ifdef APP-PLUS
|
|
98
|
+
'firstIpv4',
|
|
99
|
+
// #endif
|
|
100
|
+
// #ifdef MP-WEIXIN
|
|
101
|
+
'enableHttp2',
|
|
102
|
+
'enableQuic',
|
|
103
|
+
// #endif
|
|
104
|
+
// #ifdef MP-TOUTIAO || MP-WEIXIN
|
|
105
|
+
'enableCache',
|
|
106
|
+
// #endif
|
|
107
|
+
// #ifdef MP-WEIXIN
|
|
108
|
+
'enableHttpDNS',
|
|
109
|
+
'httpDNSServiceId',
|
|
110
|
+
'enableChunked',
|
|
111
|
+
'forceCellularNetwork',
|
|
112
|
+
// #endif
|
|
113
|
+
// #ifdef MP-ALIPAY
|
|
114
|
+
'enableCookie',
|
|
115
|
+
// #endif
|
|
116
|
+
// #ifdef MP-BAIDU
|
|
117
|
+
'cloudCache',
|
|
118
|
+
'defer'
|
|
119
|
+
// #endif
|
|
120
|
+
];
|
|
121
|
+
config = { ...config, ...mergeKeys(defaultsKeys, globalsConfig, config2) };
|
|
122
|
+
}
|
|
101
123
|
|
|
102
|
-
|
|
103
|
-
}
|
|
124
|
+
return config;
|
|
125
|
+
};
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* @param {object} response The response.
|
|
7
7
|
*/
|
|
8
8
|
export default function settle(resolve, reject, response) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
const validateStatus = response.config.validateStatus;
|
|
10
|
+
const status = response.statusCode;
|
|
11
|
+
if (status && (!validateStatus || validateStatus(status))) {
|
|
12
|
+
resolve(response);
|
|
13
|
+
} else {
|
|
14
|
+
reject(response);
|
|
15
|
+
}
|
|
16
16
|
}
|