@zfqh/uview-x 0.0.0-stage → 0.0.2

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.
Files changed (93) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +21 -0
  3. package/README.md +127 -3
  4. package/components/uv-badge/props.ts +83 -0
  5. package/components/uv-badge/uv-badge.vue +186 -0
  6. package/components/uv-button/props.ts +148 -0
  7. package/components/uv-button/uv-button.vue +565 -0
  8. package/components/uv-checkbox/props.ts +83 -0
  9. package/components/uv-checkbox/uv-checkbox.vue +403 -0
  10. package/components/uv-checkbox-group/props.ts +97 -0
  11. package/components/uv-checkbox-group/uv-checkbox-group.vue +163 -0
  12. package/components/uv-code/props.ts +48 -0
  13. package/components/uv-code/uv-code.vue +156 -0
  14. package/components/uv-dialog/props.ts +56 -0
  15. package/components/uv-dialog/uv-dialog.vue +492 -0
  16. package/components/uv-form/props.ts +59 -0
  17. package/components/uv-form/uv-form.vue +256 -0
  18. package/components/uv-form/valid.ts +1344 -0
  19. package/components/uv-form-item/props.ts +62 -0
  20. package/components/uv-form-item/uv-form-item.vue +335 -0
  21. package/components/uv-icon/icons.ts +161 -0
  22. package/components/uv-icon/props.ts +91 -0
  23. package/components/uv-icon/uv-icon.vue +208 -0
  24. package/components/uv-icon/uvicons.ttf +0 -0
  25. package/components/uv-input/props.ts +185 -0
  26. package/components/uv-input/uv-input.vue +431 -0
  27. package/components/uv-line/props.ts +42 -0
  28. package/components/uv-line/uv-line.vue +75 -0
  29. package/components/uv-line-progress/props.ts +43 -0
  30. package/components/uv-line-progress/uv-line-progress.vue +166 -0
  31. package/components/uv-loading-icon/props.ts +78 -0
  32. package/components/uv-loading-icon/uv-loading-icon.vue +226 -0
  33. package/components/uv-overlay/props.ts +38 -0
  34. package/components/uv-overlay/uv-overlay.vue +120 -0
  35. package/components/uv-popup/props.ts +101 -0
  36. package/components/uv-popup/uv-popup.vue +371 -0
  37. package/components/uv-safe-bottom/props.ts +18 -0
  38. package/components/uv-safe-bottom/uv-safe-bottom.vue +120 -0
  39. package/components/uv-status-bar/props.ts +22 -0
  40. package/components/uv-status-bar/uv-status-bar.vue +121 -0
  41. package/components/uv-tabs/props.ts +84 -0
  42. package/components/uv-tabs/uv-tabs.vue +432 -0
  43. package/components/uv-transition/props.ts +38 -0
  44. package/components/uv-transition/uv-transition.vue +170 -0
  45. package/hooks/index.ts +5 -0
  46. package/hooks/useDebounce.ts +35 -0
  47. package/hooks/useI18n.ts +95 -0
  48. package/hooks/useThrottle.ts +38 -0
  49. package/index.ts +23 -0
  50. package/libs/dayjs/index.ts +217 -0
  51. package/libs/index.ts +4 -0
  52. package/libs/luch-request/adapters/index.ts +133 -0
  53. package/libs/luch-request/core/InterceptorManager.ts +52 -0
  54. package/libs/luch-request/core/Request.ts +202 -0
  55. package/libs/luch-request/core/buildFullPath.ts +21 -0
  56. package/libs/luch-request/core/defaults.ts +34 -0
  57. package/libs/luch-request/core/dispatchRequest.ts +7 -0
  58. package/libs/luch-request/core/mergeConfig.ts +127 -0
  59. package/libs/luch-request/core/settle.ts +17 -0
  60. package/libs/luch-request/helpers/buildURL.ts +65 -0
  61. package/libs/luch-request/helpers/combineURLs.ts +15 -0
  62. package/libs/luch-request/helpers/isAbsoluteURL.ts +15 -0
  63. package/libs/luch-request/index.d.ts +197 -0
  64. package/libs/luch-request/index.ts +3 -0
  65. package/libs/luch-request/utils/clone.ts +265 -0
  66. package/libs/luch-request/utils.ts +136 -0
  67. package/locales/en.ts +78 -0
  68. package/locales/index.ts +169 -0
  69. package/locales/zh-Hans.ts +78 -0
  70. package/package.json +42 -4
  71. package/styles/color.scss +33 -0
  72. package/styles/common.scss +134 -0
  73. package/styles/components.scss +19 -0
  74. package/styles/index.scss +7 -0
  75. package/styles/theme.scss +44 -0
  76. package/styles/var.module.scss +32 -0
  77. package/styles/vue.scss +39 -0
  78. package/theme.scss +2 -0
  79. package/types/index.d.ts +66 -0
  80. package/utils/colorGradient.ts +139 -0
  81. package/utils/compat.ts +165 -0
  82. package/utils/compress.ts +34 -0
  83. package/utils/config.ts +95 -0
  84. package/utils/debounce.ts +7 -0
  85. package/utils/digit.ts +157 -0
  86. package/utils/function.ts +771 -0
  87. package/utils/http.ts +5 -0
  88. package/utils/index.ts +57 -0
  89. package/utils/locale.ts +296 -0
  90. package/utils/platform.ts +71 -0
  91. package/utils/route.ts +142 -0
  92. package/utils/test.ts +256 -0
  93. package/utils/throttle.ts +7 -0
@@ -0,0 +1,133 @@
1
+ // @ts-nocheck
2
+ import buildURL from '../helpers/buildURL'
3
+ import buildFullPath from '../core/buildFullPath'
4
+ import settle from '../core/settle'
5
+ import {isUndefined} from "../utils"
6
+
7
+ /**
8
+ * 返回可选值存在的配置
9
+ * @param {Array} keys - 可选值数组
10
+ * @param {Object} config2 - 配置
11
+ * @return {{}} - 存在的配置项
12
+ */
13
+ const mergeKeys = (keys, config2) => {
14
+ let config = {}
15
+ keys.forEach(prop => {
16
+ if (!isUndefined(config2[prop])) {
17
+ config[prop] = config2[prop]
18
+ }
19
+ })
20
+ return config
21
+ }
22
+ export default (config) => {
23
+ return new Promise((resolve, reject) => {
24
+ let fullPath = buildURL(buildFullPath(config.baseURL, config.url), config.params, config.paramsSerializer)
25
+ const _config = {
26
+ url: fullPath,
27
+ header: config.header,
28
+ complete: (response) => {
29
+ config.fullPath = fullPath
30
+ response.config = config
31
+ response.rawData = response.data
32
+ try {
33
+ let jsonParseHandle = false
34
+ const forcedJSONParsingType = typeof config.forcedJSONParsing
35
+ if (forcedJSONParsingType === 'boolean') {
36
+ jsonParseHandle = config.forcedJSONParsing
37
+ } else if (forcedJSONParsingType === 'object') {
38
+ const includesMethod = config.forcedJSONParsing.include || []
39
+ jsonParseHandle = includesMethod.includes(config.method)
40
+ }
41
+
42
+ // 对可能字符串不是json 的情况容错
43
+ if (jsonParseHandle && typeof response.data === 'string') {
44
+ response.data = JSON.parse(response.data)
45
+ }
46
+ // eslint-disable-next-line no-empty
47
+ } catch (e) {
48
+ }
49
+ settle(resolve, reject, response)
50
+ }
51
+ }
52
+ let requestTask
53
+ if (config.method === 'UPLOAD') {
54
+ delete _config.header['content-type']
55
+ delete _config.header['Content-Type']
56
+ let otherConfig = {
57
+ // #ifdef MP-ALIPAY
58
+ fileType: config.fileType,
59
+ // #endif
60
+ filePath: config.filePath,
61
+ name: config.name
62
+ }
63
+ const optionalKeys = [
64
+ // #ifdef APP-PLUS || H5
65
+ 'files',
66
+ // #endif
67
+ // #ifdef H5
68
+ 'file',
69
+ // #endif
70
+ // #ifdef H5 || APP-PLUS || MP-WEIXIN || MP-ALIPAY || MP-TOUTIAO || MP-KUAISHOU
71
+ 'timeout',
72
+ // #endif
73
+ 'formData'
74
+ ]
75
+ requestTask = uni.uploadFile({..._config, ...otherConfig, ...mergeKeys(optionalKeys, config)})
76
+ } else if (config.method === 'DOWNLOAD') {
77
+ const optionalKeys = [
78
+ // #ifdef H5 || APP-PLUS || MP-WEIXIN || MP-ALIPAY || MP-TOUTIAO || MP-KUAISHOU
79
+ 'timeout',
80
+ // #endif
81
+ // #ifdef MP
82
+ 'filePath',
83
+ // #endif
84
+ ]
85
+ requestTask = uni.downloadFile({..._config, ...mergeKeys(optionalKeys, config)})
86
+ } else {
87
+ const optionalKeys = [
88
+ 'data',
89
+ 'method',
90
+ // #ifdef H5 || APP-PLUS || MP-ALIPAY || MP-WEIXIN
91
+ 'timeout',
92
+ // #endif
93
+ 'dataType',
94
+ // #ifndef MP-ALIPAY
95
+ 'responseType',
96
+ // #endif
97
+ // #ifdef APP-PLUS
98
+ 'sslVerify',
99
+ // #endif
100
+ // #ifdef H5
101
+ 'withCredentials',
102
+ // #endif
103
+ // #ifdef APP-PLUS
104
+ 'firstIpv4',
105
+ // #endif
106
+ // #ifdef MP-WEIXIN
107
+ 'enableHttp2',
108
+ 'enableQuic',
109
+ // #endif
110
+ // #ifdef MP-TOUTIAO || MP-WEIXIN
111
+ 'enableCache',
112
+ // #endif
113
+ // #ifdef MP-WEIXIN
114
+ 'enableHttpDNS',
115
+ 'httpDNSServiceId',
116
+ 'enableChunked',
117
+ 'forceCellularNetwork',
118
+ // #endif
119
+ // #ifdef MP-ALIPAY
120
+ 'enableCookie',
121
+ // #endif
122
+ // #ifdef MP-BAIDU
123
+ 'cloudCache',
124
+ 'defer'
125
+ // #endif
126
+ ]
127
+ requestTask = uni.request({..._config, ...mergeKeys(optionalKeys, config)})
128
+ }
129
+ if (config.getTask) {
130
+ config.getTask(requestTask, config)
131
+ }
132
+ })
133
+ }
@@ -0,0 +1,52 @@
1
+ // @ts-nocheck
2
+ 'use strict'
3
+
4
+
5
+ function InterceptorManager() {
6
+ this.handlers = []
7
+ }
8
+
9
+ /**
10
+ * Add a new interceptor to the stack
11
+ *
12
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
13
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
14
+ *
15
+ * @return {Number} An ID used to remove interceptor later
16
+ */
17
+ InterceptorManager.prototype.use = function use(fulfilled, rejected) {
18
+ this.handlers.push({
19
+ fulfilled: fulfilled,
20
+ rejected: rejected
21
+ })
22
+ return this.handlers.length - 1
23
+ }
24
+
25
+ /**
26
+ * Remove an interceptor from the stack
27
+ *
28
+ * @param {Number} id The ID that was returned by `use`
29
+ */
30
+ InterceptorManager.prototype.eject = function eject(id) {
31
+ if (this.handlers[id]) {
32
+ this.handlers[id] = null
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Iterate over all the registered interceptors
38
+ *
39
+ * This method is particularly useful for skipping over any
40
+ * interceptors that may have become `null` calling `eject`.
41
+ *
42
+ * @param {Function} fn The function to call for each interceptor
43
+ */
44
+ InterceptorManager.prototype.forEach = function forEach(fn) {
45
+ this.handlers.forEach(h => {
46
+ if (h !== null) {
47
+ fn(h)
48
+ }
49
+ })
50
+ }
51
+
52
+ export default InterceptorManager
@@ -0,0 +1,202 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @Class Request
4
+ * @description luch-request http请求插件
5
+ * @Author lu-ch
6
+ * @Email webwork.s@qq.com
7
+ * 文档: https://www.quanzhan.co/luch-request/
8
+ * github: https://github.com/lei-mu/luch-request
9
+ * DCloud: http://ext.dcloud.net.cn/plugin?id=392
10
+ */
11
+
12
+
13
+ import dispatchRequest from './dispatchRequest'
14
+ import InterceptorManager from './InterceptorManager'
15
+ import mergeConfig from './mergeConfig'
16
+ import defaults from './defaults'
17
+ import { isPlainObject } from '../utils'
18
+ import clone from '../utils/clone'
19
+
20
+ export default class Request {
21
+ /**
22
+ * @param {Object} arg - 全局配置
23
+ * @param {String} arg.baseURL - 全局根路径
24
+ * @param {Object} arg.header - 全局header
25
+ * @param {String} arg.method = [GET|POST|PUT|DELETE|CONNECT|HEAD|OPTIONS|TRACE] - 全局默认请求方式
26
+ * @param {String} arg.dataType = [json] - 全局默认的dataType
27
+ * @param {String} arg.responseType = [text|arraybuffer] - 全局默认的responseType。支付宝小程序不支持
28
+ * @param {Object} arg.custom - 全局默认的自定义参数
29
+ * @param {Number} arg.timeout - 全局默认的超时时间,单位 ms。默认60000。H5(HBuilderX 2.9.9+)、APP(HBuilderX 2.9.9+)、微信小程序(2.10.0)、支付宝小程序
30
+ * @param {Boolean} arg.sslVerify - 全局默认的是否验证 ssl 证书。默认true.仅App安卓端支持(HBuilderX 2.3.3+)
31
+ * @param {Boolean} arg.withCredentials - 全局默认的跨域请求时是否携带凭证(cookies)。默认false。仅H5支持(HBuilderX 2.6.15+)
32
+ * @param {Boolean} arg.firstIpv4 - 全DNS解析时优先使用ipv4。默认false。仅 App-Android 支持 (HBuilderX 2.8.0+)
33
+ * @param {Function(statusCode):Boolean} arg.validateStatus - 全局默认的自定义验证器。默认statusCode >= 200 && statusCode < 300
34
+ */
35
+ constructor(arg = {}) {
36
+ if (!isPlainObject(arg)) {
37
+ arg = {}
38
+ console.warn('设置全局参数必须接收一个Object')
39
+ }
40
+ this.config = clone({...defaults, ...arg})
41
+ this.interceptors = {
42
+ request: new InterceptorManager(),
43
+ response: new InterceptorManager()
44
+ }
45
+ }
46
+
47
+ /**
48
+ * @Function
49
+ * @param {Request~setConfigCallback} f - 设置全局默认配置
50
+ */
51
+ setConfig(f) {
52
+ this.config = f(this.config)
53
+ }
54
+
55
+ middleware(config) {
56
+ config = mergeConfig(this.config, config)
57
+ let chain = [dispatchRequest, undefined]
58
+ let promise = Promise.resolve(config)
59
+
60
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
61
+ chain.unshift(interceptor.fulfilled, interceptor.rejected)
62
+ })
63
+
64
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
65
+ chain.push(interceptor.fulfilled, interceptor.rejected)
66
+ })
67
+
68
+ while (chain.length) {
69
+ promise = promise.then(chain.shift(), chain.shift())
70
+ }
71
+
72
+ return promise
73
+ }
74
+
75
+ /**
76
+ * @Function
77
+ * @param {Object} config - 请求配置项
78
+ * @prop {String} options.url - 请求路径
79
+ * @prop {Object} options.data - 请求参数
80
+ * @prop {Object} [options.responseType = config.responseType] [text|arraybuffer] - 响应的数据类型
81
+ * @prop {Object} [options.dataType = config.dataType] - 如果设为 json,会尝试对返回的数据做一次 JSON.parse
82
+ * @prop {Object} [options.header = config.header] - 请求header
83
+ * @prop {Object} [options.method = config.method] - 请求方法
84
+ * @returns {Promise<unknown>}
85
+ */
86
+ request(config = {}) {
87
+ return this.middleware(config)
88
+ }
89
+
90
+ get(url, options = {}) {
91
+ return this.middleware({
92
+ url,
93
+ method: 'GET',
94
+ ...options
95
+ })
96
+ }
97
+
98
+ post(url, data, options = {}) {
99
+ return this.middleware({
100
+ url,
101
+ data,
102
+ method: 'POST',
103
+ ...options
104
+ })
105
+ }
106
+
107
+ // #ifndef MP-ALIPAY || MP-KUAISHOU || MP-JD
108
+ put(url, data, options = {}) {
109
+ return this.middleware({
110
+ url,
111
+ data,
112
+ method: 'PUT',
113
+ ...options
114
+ })
115
+ }
116
+
117
+ // #endif
118
+
119
+ // #ifdef APP-PLUS || H5 || MP-WEIXIN || MP-BAIDU
120
+ delete(url, data, options = {}) {
121
+ return this.middleware({
122
+ url,
123
+ data,
124
+ method: 'DELETE',
125
+ ...options
126
+ })
127
+ }
128
+
129
+ // #endif
130
+
131
+ // #ifdef H5 || MP-WEIXIN
132
+ connect(url, data, options = {}) {
133
+ return this.middleware({
134
+ url,
135
+ data,
136
+ method: 'CONNECT',
137
+ ...options
138
+ })
139
+ }
140
+
141
+ // #endif
142
+
143
+ // #ifdef H5 || MP-WEIXIN || MP-BAIDU
144
+ head(url, data, options = {}) {
145
+ return this.middleware({
146
+ url,
147
+ data,
148
+ method: 'HEAD',
149
+ ...options
150
+ })
151
+ }
152
+
153
+ // #endif
154
+
155
+ // #ifdef APP-PLUS || H5 || MP-WEIXIN || MP-BAIDU
156
+ options(url, data, options = {}) {
157
+ return this.middleware({
158
+ url,
159
+ data,
160
+ method: 'OPTIONS',
161
+ ...options
162
+ })
163
+ }
164
+
165
+ // #endif
166
+
167
+ // #ifdef H5 || MP-WEIXIN
168
+ trace(url, data, options = {}) {
169
+ return this.middleware({
170
+ url,
171
+ data,
172
+ method: 'TRACE',
173
+ ...options
174
+ })
175
+ }
176
+
177
+ // #endif
178
+
179
+ upload(url, config = {}) {
180
+ config.url = url
181
+ config.method = 'UPLOAD'
182
+ return this.middleware(config)
183
+ }
184
+
185
+ download(url, config = {}) {
186
+ config.url = url
187
+ config.method = 'DOWNLOAD'
188
+ return this.middleware(config)
189
+ }
190
+
191
+ get version () {
192
+ return '3.1.0'
193
+ }
194
+ }
195
+
196
+
197
+ /**
198
+ * setConfig回调
199
+ * @return {Object} - 返回操作后的config
200
+ * @callback Request~setConfigCallback
201
+ * @param {Object} config - 全局默认config
202
+ */
@@ -0,0 +1,21 @@
1
+ // @ts-nocheck
2
+ 'use strict'
3
+
4
+ import isAbsoluteURL from '../helpers/isAbsoluteURL'
5
+ import combineURLs from '../helpers/combineURLs'
6
+
7
+ /**
8
+ * Creates a new URL by combining the baseURL with the requestedURL,
9
+ * only when the requestedURL is not already an absolute URL.
10
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
11
+ *
12
+ * @param {string} baseURL The base URL
13
+ * @param {string} requestedURL Absolute or relative URL to combine
14
+ * @returns {string} The combined full path
15
+ */
16
+ export default function buildFullPath(baseURL, requestedURL) {
17
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
18
+ return combineURLs(baseURL, requestedURL)
19
+ }
20
+ return requestedURL
21
+ }
@@ -0,0 +1,34 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * 默认的全局配置
4
+ */
5
+
6
+
7
+ export default {
8
+ baseURL: '',
9
+ header: {},
10
+ method: 'GET',
11
+ dataType: 'json',
12
+ paramsSerializer: null,
13
+ // #ifndef MP-ALIPAY
14
+ responseType: 'text',
15
+ // #endif
16
+ custom: {},
17
+ // #ifdef H5 || APP-PLUS || MP-WEIXIN || MP-ALIPAY || MP-TOUTIAO || MP-KUAISHOU
18
+ timeout: 60000,
19
+ // #endif
20
+ // #ifdef APP-PLUS
21
+ sslVerify: true,
22
+ // #endif
23
+ // #ifdef H5
24
+ withCredentials: false,
25
+ // #endif
26
+ // #ifdef APP-PLUS
27
+ firstIpv4: false,
28
+ // #endif
29
+ validateStatus: function validateStatus(status) {
30
+ return status >= 200 && status < 300
31
+ },
32
+ // 是否尝试将响应数据json化
33
+ forcedJSONParsing: true
34
+ }
@@ -0,0 +1,7 @@
1
+ // @ts-nocheck
2
+ import adapter from '../adapters/index'
3
+
4
+
5
+ export default (config) => {
6
+ return adapter(config)
7
+ }
@@ -0,0 +1,127 @@
1
+ // @ts-nocheck
2
+ import {deepMerge, isUndefined} from '../utils'
3
+
4
+ /**
5
+ * 合并局部配置优先的配置,如果局部有该配置项则用局部,如果全局有该配置项则用全局
6
+ * @param {Array} keys - 配置项
7
+ * @param {Object} globalsConfig - 当前的全局配置
8
+ * @param {Object} config2 - 局部配置
9
+ * @return {{}}
10
+ */
11
+ const mergeKeys = (keys, globalsConfig, config2) => {
12
+ let config = {}
13
+ keys.forEach(prop => {
14
+ if (!isUndefined(config2[prop])) {
15
+ config[prop] = config2[prop]
16
+ } else if (!isUndefined(globalsConfig[prop])) {
17
+ config[prop] = globalsConfig[prop]
18
+ }
19
+ })
20
+ return config
21
+ }
22
+ /**
23
+ *
24
+ * @param globalsConfig - 当前实例的全局配置
25
+ * @param config2 - 当前的局部配置
26
+ * @return - 合并后的配置
27
+ */
28
+ export default (globalsConfig, config2 = {}) => {
29
+ const method = config2.method || globalsConfig.method || 'GET'
30
+ let config = {
31
+ baseURL: config2.baseURL || globalsConfig.baseURL || '',
32
+ method: method,
33
+ url: config2.url || '',
34
+ params: config2.params || {},
35
+ custom: {...(globalsConfig.custom || {}), ...(config2.custom || {})},
36
+ header: deepMerge(globalsConfig.header || {}, config2.header || {})
37
+ }
38
+ const defaultToConfig2Keys = ['getTask', 'validateStatus', 'paramsSerializer', 'forcedJSONParsing']
39
+ config = {...config, ...mergeKeys(defaultToConfig2Keys, globalsConfig, config2)}
40
+
41
+ // eslint-disable-next-line no-empty
42
+ if (method === 'DOWNLOAD') {
43
+ const downloadKeys = [
44
+ // #ifdef H5 || APP-PLUS || MP-WEIXIN || MP-ALIPAY || MP-TOUTIAO || MP-KUAISHOU
45
+ 'timeout',
46
+ // #endif
47
+ // #ifdef MP
48
+ 'filePath',
49
+ // #endif
50
+ ]
51
+ config = {...config, ...mergeKeys(downloadKeys, globalsConfig, config2)}
52
+ } else if (method === 'UPLOAD') {
53
+ delete config.header['content-type']
54
+ delete config.header['Content-Type']
55
+ const uploadKeys = [
56
+ // #ifdef APP-PLUS || H5
57
+ 'files',
58
+ // #endif
59
+ // #ifdef MP-ALIPAY
60
+ 'fileType',
61
+ // #endif
62
+ // #ifdef H5
63
+ 'file',
64
+ // #endif
65
+ 'filePath',
66
+ 'name',
67
+ // #ifdef H5 || APP-PLUS || MP-WEIXIN || MP-ALIPAY || MP-TOUTIAO || MP-KUAISHOU
68
+ 'timeout',
69
+ // #endif
70
+ 'formData',
71
+ ]
72
+ uploadKeys.forEach(prop => {
73
+ if (!isUndefined(config2[prop])) {
74
+ config[prop] = config2[prop]
75
+ }
76
+ })
77
+ // #ifdef H5 || APP-PLUS || MP-WEIXIN || MP-ALIPAY || MP-TOUTIAO || MP-KUAISHOU
78
+ if (isUndefined(config.timeout) && !isUndefined(globalsConfig.timeout)) {
79
+ config['timeout'] = globalsConfig['timeout']
80
+ }
81
+ // #endif
82
+ } else {
83
+ const defaultsKeys = [
84
+ 'data',
85
+ // #ifdef H5 || APP-PLUS || MP-ALIPAY || MP-WEIXIN
86
+ 'timeout',
87
+ // #endif
88
+ 'dataType',
89
+ // #ifndef MP-ALIPAY
90
+ 'responseType',
91
+ // #endif
92
+ // #ifdef APP-PLUS
93
+ 'sslVerify',
94
+ // #endif
95
+ // #ifdef H5
96
+ 'withCredentials',
97
+ // #endif
98
+ // #ifdef APP-PLUS
99
+ 'firstIpv4',
100
+ // #endif
101
+ // #ifdef MP-WEIXIN
102
+ 'enableHttp2',
103
+ 'enableQuic',
104
+ // #endif
105
+ // #ifdef MP-TOUTIAO || MP-WEIXIN
106
+ 'enableCache',
107
+ // #endif
108
+ // #ifdef MP-WEIXIN
109
+ 'enableHttpDNS',
110
+ 'httpDNSServiceId',
111
+ 'enableChunked',
112
+ 'forceCellularNetwork',
113
+ // #endif
114
+ // #ifdef MP-ALIPAY
115
+ 'enableCookie',
116
+ // #endif
117
+ // #ifdef MP-BAIDU
118
+ 'cloudCache',
119
+ 'defer'
120
+ // #endif
121
+
122
+ ]
123
+ config = {...config, ...mergeKeys(defaultsKeys, globalsConfig, config2)}
124
+ }
125
+
126
+ return config
127
+ }
@@ -0,0 +1,17 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * Resolve or reject a Promise based on response status.
4
+ *
5
+ * @param {Function} resolve A function that resolves the promise.
6
+ * @param {Function} reject A function that rejects the promise.
7
+ * @param {object} response The response.
8
+ */
9
+ export default function settle(resolve, reject, response) {
10
+ const validateStatus = response.config.validateStatus
11
+ const status = response.statusCode
12
+ if (status && (!validateStatus || validateStatus(status))) {
13
+ resolve(response)
14
+ } else {
15
+ reject(response)
16
+ }
17
+ }
@@ -0,0 +1,65 @@
1
+ // @ts-nocheck
2
+ 'use strict'
3
+
4
+ import * as utils from './../utils'
5
+
6
+ function encode(val) {
7
+ return encodeURIComponent(val).replace(/%40/gi, '@').replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']')
8
+ }
9
+
10
+ /**
11
+ * Build a URL by appending params to the end
12
+ *
13
+ * @param {string} url The base of the url (e.g., http://www.google.com)
14
+ * @param {object} [params] The params to be appended
15
+ * @returns {string} The formatted url
16
+ */
17
+ export default function buildURL(url, params, paramsSerializer) {
18
+ /*eslint no-param-reassign:0*/
19
+ if (!params) {
20
+ return url
21
+ }
22
+
23
+ var serializedParams
24
+ if (paramsSerializer) {
25
+ serializedParams = paramsSerializer(params)
26
+ } else if (utils.isURLSearchParams(params)) {
27
+ serializedParams = params.toString()
28
+ } else {
29
+ var parts = []
30
+
31
+ utils.forEach(params, function serialize(val, key) {
32
+ if (val === null || typeof val === 'undefined') {
33
+ return
34
+ }
35
+
36
+ if (utils.isArray(val)) {
37
+ key = key + '[]'
38
+ } else {
39
+ val = [val]
40
+ }
41
+
42
+ utils.forEach(val, function parseValue(v) {
43
+ if (utils.isDate(v)) {
44
+ v = v.toISOString()
45
+ } else if (utils.isObject(v)) {
46
+ v = JSON.stringify(v)
47
+ }
48
+ parts.push(encode(key) + '=' + encode(v))
49
+ })
50
+ })
51
+
52
+ serializedParams = parts.join('&')
53
+ }
54
+
55
+ if (serializedParams) {
56
+ var hashmarkIndex = url.indexOf('#')
57
+ if (hashmarkIndex !== -1) {
58
+ url = url.slice(0, hashmarkIndex)
59
+ }
60
+
61
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams
62
+ }
63
+
64
+ return url
65
+ }
@@ -0,0 +1,15 @@
1
+ // @ts-nocheck
2
+ 'use strict'
3
+
4
+ /**
5
+ * Creates a new URL by combining the specified URLs
6
+ *
7
+ * @param {string} baseURL The base URL
8
+ * @param {string} relativeURL The relative URL
9
+ * @returns {string} The combined URL
10
+ */
11
+ export default function combineURLs(baseURL, relativeURL) {
12
+ return relativeURL
13
+ ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
14
+ : baseURL
15
+ }
@@ -0,0 +1,15 @@
1
+ // @ts-nocheck
2
+ 'use strict'
3
+
4
+ /**
5
+ * Determines whether the specified URL is absolute
6
+ *
7
+ * @param {string} url The URL to test
8
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
9
+ */
10
+ export default function isAbsoluteURL(url) {
11
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
12
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
13
+ // by any combination of letters, digits, plus, period, or hyphen.
14
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url)
15
+ }