@10yun/cv-mobile-ui 0.5.37 → 0.5.39

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 (36) hide show
  1. package/README.md +1 -1
  2. package/libs/amap-wx.130.js +485 -0
  3. package/libs/amap-wx.js +517 -0
  4. package/libs/highlight/github-dark.min.css +10 -0
  5. package/libs/highlight/highlight-uni.min.js +5256 -0
  6. package/libs/html-parser.js +352 -0
  7. package/libs/jweixin-module.js +1 -0
  8. package/libs/markdown-it.min.js +2 -0
  9. package/libs/md5.js +774 -0
  10. package/libs/permission.js +244 -0
  11. package/libs/qqmap-wx-jssdk.js +1178 -0
  12. package/package.json +2 -2
  13. package/plugins/luch-request/utils/clone.js +28 -32
  14. package/plugins/{map/uniMap.js → uniMap.js} +0 -20
  15. package/ui-cv/components/cv-code-sms/cv-code-sms.vue +9 -0
  16. package/uview-plus/libs/ctocode/index.js +1 -10
  17. package/uview-plus/libs/luch-request/adapters/index.js +113 -79
  18. package/uview-plus/libs/luch-request/core/InterceptorManager.js +19 -19
  19. package/uview-plus/libs/luch-request/core/Request.js +146 -146
  20. package/uview-plus/libs/luch-request/core/buildFullPath.js +7 -7
  21. package/uview-plus/libs/luch-request/core/defaults.js +27 -24
  22. package/uview-plus/libs/luch-request/core/dispatchRequest.js +4 -2
  23. package/uview-plus/libs/luch-request/core/mergeConfig.js +106 -84
  24. package/uview-plus/libs/luch-request/core/settle.js +7 -7
  25. package/uview-plus/libs/luch-request/helpers/buildURL.js +50 -48
  26. package/uview-plus/libs/luch-request/helpers/combineURLs.js +2 -4
  27. package/uview-plus/libs/luch-request/helpers/isAbsoluteURL.js +5 -5
  28. package/uview-plus/libs/luch-request/index.d.ts +184 -103
  29. package/uview-plus/libs/luch-request/index.js +2 -3
  30. package/uview-plus/libs/luch-request/readme.md +3 -0
  31. package/uview-plus/libs/luch-request/utils/clone.js +28 -32
  32. package/uview-plus/libs/luch-request/utils.js +41 -41
  33. package/plugins/map/lib/amap-wx.js +0 -1
  34. package/plugins/request.js +0 -571
  35. /package/{plugins/map → libs}/amqp-wx.js +0 -0
  36. /package/{plugins/map → libs}/qqmap.js +0 -0
@@ -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
- constructor(arg = {}) {
37
- // console.info('初始化luch-request')
38
- if (!isPlainObject(arg)) {
39
- arg = {}
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
- setConfig(f) {
54
- this.config = f(this.config)
55
- }
49
+ setConfig(f) {
50
+ this.config = f(this.config);
51
+ }
56
52
 
57
- middleware(config) {
58
- config = mergeConfig(this.config, config)
59
- const chain = [dispatchRequest, undefined]
60
- let promise = Promise.resolve(config)
53
+ middleware(config) {
54
+ config = mergeConfig(this.config, config);
55
+ let chain = [dispatchRequest, undefined];
56
+ let promise = Promise.resolve(config);
61
57
 
62
- this.interceptors.request.forEach((interceptor) => {
63
- chain.unshift(interceptor.fulfilled, interceptor.rejected)
64
- })
58
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
59
+ chain.unshift(interceptor.fulfilled, interceptor.rejected);
60
+ });
65
61
 
66
- this.interceptors.response.forEach((interceptor) => {
67
- chain.push(interceptor.fulfilled, interceptor.rejected)
68
- })
62
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
63
+ chain.push(interceptor.fulfilled, interceptor.rejected);
64
+ });
69
65
 
70
- while (chain.length) {
71
- promise = promise.then(chain.shift(), chain.shift())
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
- request(config = {}) {
89
- return this.middleware(config)
90
- }
91
-
92
- get(url, options = {}) {
93
- return this.middleware({
94
- url,
95
- method: 'GET',
96
- ...options
97
- })
98
- }
99
-
100
- post(url, data, options = {}) {
101
- return this.middleware({
102
- url,
103
- data,
104
- method: 'POST',
105
- ...options
106
- })
107
- }
108
-
109
- // #ifndef MP-ALIPAY
110
- put(url, data, options = {}) {
111
- return this.middleware({
112
- url,
113
- data,
114
- method: 'PUT',
115
- ...options
116
- })
117
- }
118
-
119
- // #endif
120
-
121
- // #ifdef APP-PLUS || H5 || MP-WEIXIN || MP-BAIDU
122
- delete(url, data, options = {}) {
123
- return this.middleware({
124
- url,
125
- data,
126
- method: 'DELETE',
127
- ...options
128
- })
129
- }
130
-
131
- // #endif
132
-
133
- // #ifdef H5 || MP-WEIXIN
134
- connect(url, data, options = {}) {
135
- return this.middleware({
136
- url,
137
- data,
138
- method: 'CONNECT',
139
- ...options
140
- })
141
- }
142
-
143
- // #endif
144
-
145
- // #ifdef H5 || MP-WEIXIN || MP-BAIDU
146
- head(url, data, options = {}) {
147
- return this.middleware({
148
- url,
149
- data,
150
- method: 'HEAD',
151
- ...options
152
- })
153
- }
154
-
155
- // #endif
156
-
157
- // #ifdef APP-PLUS || H5 || MP-WEIXIN || MP-BAIDU
158
- options(url, data, options = {}) {
159
- return this.middleware({
160
- url,
161
- data,
162
- method: 'OPTIONS',
163
- ...options
164
- })
165
- }
166
-
167
- // #endif
168
-
169
- // #ifdef H5 || MP-WEIXIN
170
- trace(url, data, options = {}) {
171
- return this.middleware({
172
- url,
173
- data,
174
- method: 'TRACE',
175
- ...options
176
- })
177
- }
178
-
179
- // #endif
180
-
181
- upload(url, config = {}) {
182
- config.url = url
183
- config.method = 'UPLOAD'
184
- return this.middleware(config)
185
- }
186
-
187
- download(url, config = {}) {
188
- config.url = url
189
- config.method = 'DOWNLOAD'
190
- return this.middleware(config)
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
- if (baseURL && !isAbsoluteURL(requestedURL)) {
17
- return combineURLs(baseURL, requestedURL)
18
- }
19
- return requestedURL
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
- baseURL: '',
7
- header: {},
8
- method: 'GET',
9
- dataType: 'json',
10
- // #ifndef MP-ALIPAY
11
- responseType: 'text',
12
- // #endif
13
- custom: {},
14
- // #ifdef H5 || APP-PLUS || MP-ALIPAY || MP-WEIXIN
15
- timeout: 60000,
16
- // #endif
17
- // #ifdef APP-PLUS
18
- sslVerify: true,
19
- // #endif
20
- // #ifdef H5
21
- withCredentials: false,
22
- // #endif
23
- // #ifdef APP-PLUS
24
- firstIpv4: false,
25
- // #endif
26
- validateStatus: function validateStatus(status) {
27
- return status >= 200 && status < 300
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,3 +1,5 @@
1
- import adapter from '../adapters/index'
1
+ import adapter from '../adapters/index';
2
2
 
3
- export default (config) => adapter(config)
3
+ export default (config) => {
4
+ return adapter(config);
5
+ };
@@ -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
- const 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
- }
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
- const method = config2.method || globalsConfig.method || 'GET'
29
- let config = {
30
- baseURL: globalsConfig.baseURL || '',
31
- 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']
38
- config = { ...config, ...mergeKeys(defaultToConfig2Keys, globalsConfig, config2) }
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
- // eslint-disable-next-line no-empty
41
- if (method === 'DOWNLOAD') {
42
- // #ifdef H5 || APP-PLUS
43
- if (!isUndefined(config2.timeout)) {
44
- config.timeout = config2.timeout
45
- } else if (!isUndefined(globalsConfig.timeout)) {
46
- config.timeout = globalsConfig.timeout
47
- }
48
- // #endif
49
- } else if (method === 'UPLOAD') {
50
- delete config.header['content-type']
51
- delete config.header['Content-Type']
52
- const uploadKeys = [
53
- // #ifdef APP-PLUS || H5
54
- 'files',
55
- // #endif
56
- // #ifdef MP-ALIPAY
57
- 'fileType',
58
- // #endif
59
- // #ifdef H5
60
- 'file',
61
- // #endif
62
- 'filePath',
63
- 'name',
64
- // #ifdef H5 || APP-PLUS
65
- 'timeout',
66
- // #endif
67
- 'formData'
68
- ]
69
- uploadKeys.forEach((prop) => {
70
- if (!isUndefined(config2[prop])) {
71
- config[prop] = config2[prop]
72
- }
73
- })
74
- // #ifdef H5 || APP-PLUS
75
- if (isUndefined(config.timeout) && !isUndefined(globalsConfig.timeout)) {
76
- config.timeout = globalsConfig.timeout
77
- }
78
- // #endif
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
- return config
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
- const { validateStatus } = response.config
10
- const status = response.statusCode
11
- if (status && (!validateStatus || validateStatus(status))) {
12
- resolve(response)
13
- } else {
14
- reject(response)
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
  }