nvue3 1.1.16 → 1.1.17
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 +3 -3
- package/src/http.js +33 -11
- package/src/kernel.js +9 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nvue3",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.17",
|
|
4
4
|
"description": "for uniapp & vue3",
|
|
5
5
|
"main": "src/kernel.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"author": "",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"nodejs_patch": "^1.0.
|
|
12
|
+
"nodejs_patch": "^1.0.17"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"nodejs_patch": "^1.0.
|
|
15
|
+
"nodejs_patch": "^1.0.17"
|
|
16
16
|
}
|
|
17
17
|
}
|
package/src/http.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
const tstShow = 350;
|
|
5
5
|
const isDebug = (process.env.NODE_ENV === 'development');
|
|
6
6
|
// const isDebug = true;
|
|
7
|
+
const nextPost = [];
|
|
7
8
|
|
|
8
9
|
const baseResp = {
|
|
9
10
|
success: 1,
|
|
@@ -50,6 +51,11 @@ const _request = class {
|
|
|
50
51
|
throw new Error('api 请求目标必须是string类型地址,且必填');
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
if ((nextPost.length > 0) && (this.method === 'POST')) {
|
|
55
|
+
data._append = JSON.parse(JSON.stringify(nextPost));
|
|
56
|
+
nextPost.length = 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
53
59
|
let host = config.path;
|
|
54
60
|
|
|
55
61
|
if (uri[0] === '!') { //uri第1个字符为!,静默处理
|
|
@@ -330,7 +336,7 @@ function doComplete(request, res, resolve, reject) {
|
|
|
330
336
|
}
|
|
331
337
|
|
|
332
338
|
|
|
333
|
-
function doRequest(request) {
|
|
339
|
+
async function doRequest(request) {
|
|
334
340
|
|
|
335
341
|
if (request.toast) {
|
|
336
342
|
request.loading = true;
|
|
@@ -389,7 +395,7 @@ function thisPost(api, data = {}) {
|
|
|
389
395
|
* save=`s/upload/save/`
|
|
390
396
|
*
|
|
391
397
|
*/
|
|
392
|
-
function doUploadAliYun(uri, option) {
|
|
398
|
+
async function doUploadAliYun(uri, option) {
|
|
393
399
|
|
|
394
400
|
return new Promise(async (resolve, reject) => {
|
|
395
401
|
let { file, mime, used, source } = option;
|
|
@@ -472,7 +478,7 @@ function doUploadAliYun(uri, option) {
|
|
|
472
478
|
* 操作频率检查
|
|
473
479
|
* @param {Object} api
|
|
474
480
|
*/
|
|
475
|
-
function FrequencyDetection(api) {
|
|
481
|
+
async function FrequencyDetection(api) {
|
|
476
482
|
|
|
477
483
|
if (api[0] === '@') return null; //不检查频率
|
|
478
484
|
|
|
@@ -494,6 +500,7 @@ function FrequencyDetection(api) {
|
|
|
494
500
|
}
|
|
495
501
|
|
|
496
502
|
|
|
503
|
+
|
|
497
504
|
export default class {
|
|
498
505
|
processor = null;
|
|
499
506
|
|
|
@@ -503,27 +510,42 @@ export default class {
|
|
|
503
510
|
if (isDebug) console.log(config);
|
|
504
511
|
}
|
|
505
512
|
|
|
506
|
-
get(api, data = {}) {
|
|
513
|
+
async get(api, data = {}) {
|
|
507
514
|
if (config.detection > 0) {
|
|
508
|
-
const fd = FrequencyDetection(api);
|
|
515
|
+
const fd = await FrequencyDetection(api);
|
|
509
516
|
if (fd) return fd;
|
|
510
517
|
}
|
|
511
518
|
|
|
512
|
-
return doRequest(new _request(api, data, 'get'));
|
|
519
|
+
return await doRequest(new _request(api, data, 'get'));
|
|
513
520
|
}
|
|
514
521
|
|
|
515
|
-
post(api, data = {}) {
|
|
522
|
+
async post(api, data = {}) {
|
|
516
523
|
if (config.detection > 0) {
|
|
517
|
-
const fd = FrequencyDetection(api);
|
|
524
|
+
const fd = await FrequencyDetection(api);
|
|
518
525
|
if (fd) return fd;
|
|
519
526
|
}
|
|
520
527
|
|
|
521
|
-
return doRequest(new _request(api, data, 'post'));
|
|
528
|
+
return await doRequest(new _request(api, data, 'post'));
|
|
522
529
|
}
|
|
523
530
|
|
|
531
|
+
next(data) {
|
|
532
|
+
/**
|
|
533
|
+
* 下一次post时请求时携带,后端用_append获取
|
|
534
|
+
* 主要用于发送不紧急的数据,没必要发起一次http请求
|
|
535
|
+
* 数据是array,后端遍历读取即可
|
|
536
|
+
*/
|
|
537
|
+
if (data === undefined) return JSON.parse(JSON.stringify(nextPost));
|
|
538
|
+
|
|
539
|
+
if (data === 'clear') {
|
|
540
|
+
nextPost.length = 0;
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
nextPost.push(data);
|
|
545
|
+
}
|
|
524
546
|
|
|
525
|
-
upload(uri, option) {
|
|
526
|
-
return doUploadAliYun(uri, option);
|
|
547
|
+
async upload(uri, option) {
|
|
548
|
+
return await doUploadAliYun(uri, option);
|
|
527
549
|
}
|
|
528
550
|
|
|
529
551
|
|
package/src/kernel.js
CHANGED
|
@@ -53,12 +53,14 @@ export default {
|
|
|
53
53
|
|
|
54
54
|
if (!config.http.error) return;
|
|
55
55
|
|
|
56
|
-
app.config.errorHandler = (error, instance,
|
|
56
|
+
app.config.errorHandler = (error, instance, trace) => {
|
|
57
57
|
try {
|
|
58
58
|
if (error === lastError) return;
|
|
59
59
|
lastError = error;
|
|
60
|
-
console.log({ error, instance,
|
|
61
|
-
|
|
60
|
+
// console.log({ error, instance, trace });
|
|
61
|
+
console.trace(error)
|
|
62
|
+
console.trace(trace)
|
|
63
|
+
http.post(`!@${config.http.error}/error`, { error, instance, trace });
|
|
62
64
|
}
|
|
63
65
|
catch (err) {
|
|
64
66
|
console.log({ err })
|
|
@@ -69,8 +71,10 @@ export default {
|
|
|
69
71
|
try {
|
|
70
72
|
if (error === lastWarn) return;
|
|
71
73
|
lastWarn = error;
|
|
72
|
-
console.log({ error, instance, trace });
|
|
73
|
-
|
|
74
|
+
// console.log({ error, instance, trace });
|
|
75
|
+
console.trace(error)
|
|
76
|
+
console.trace(trace)
|
|
77
|
+
http.post(`!@${config.http.error}/warn`, { error, instance, trace });
|
|
74
78
|
}
|
|
75
79
|
catch (err) {
|
|
76
80
|
console.log({ err })
|