fast-vue-multi-pages 1.0.5 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/FastVueMultiTool.d.ts +5 -0
- package/dist/cjs/FastVueMultiTool.js +5 -0
- package/dist/cjs/http/FastVueMultiHttp.d.ts +5 -90
- package/dist/cjs/http/FastVueMultiHttp.js +6 -148
- package/dist/cjs/http/FastVueMultiSimpleJsonResponse.d.ts +67 -0
- package/dist/cjs/http/FastVueMultiSimpleJsonResponse.js +126 -0
- package/dist/cjs/http/FastVueMultiSimpleRequestConfig.d.ts +21 -0
- package/dist/cjs/http/FastVueMultiSimpleRequestConfig.js +25 -0
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/other/FastVueMultiBase64.d.ts +12 -0
- package/dist/cjs/other/FastVueMultiBase64.js +22 -0
- package/dist/cjs/other/FastVueMultiFile.d.ts +11 -0
- package/dist/cjs/other/FastVueMultiFile.js +36 -2
- package/dist/esm/FastVueMultiTool.d.ts +5 -0
- package/dist/esm/FastVueMultiTool.js +5 -1
- package/dist/esm/http/FastVueMultiHttp.d.ts +5 -90
- package/dist/esm/http/FastVueMultiHttp.js +5 -152
- package/dist/esm/http/FastVueMultiSimpleJsonResponse.d.ts +67 -0
- package/dist/esm/http/FastVueMultiSimpleJsonResponse.js +127 -0
- package/dist/esm/http/FastVueMultiSimpleRequestConfig.d.ts +21 -0
- package/dist/esm/http/FastVueMultiSimpleRequestConfig.js +30 -0
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.js +4 -2
- package/dist/esm/other/FastVueMultiBase64.d.ts +12 -0
- package/dist/esm/other/FastVueMultiBase64.js +27 -0
- package/dist/esm/other/FastVueMultiFile.d.ts +11 -0
- package/dist/esm/other/FastVueMultiFile.js +68 -23
- package/package.json +1 -1
@@ -6,7 +6,7 @@ class FastVueMultiFile {
|
|
6
6
|
* 弹出上传文件的选择框
|
7
7
|
* @param multi
|
8
8
|
*/
|
9
|
-
static showUploadImage(multi) {
|
9
|
+
static async showUploadImage(multi) {
|
10
10
|
return new Promise((resolve, reject) => {
|
11
11
|
let inputElement = document.createElement('input');
|
12
12
|
let event = new MouseEvent('click');
|
@@ -24,7 +24,10 @@ class FastVueMultiFile {
|
|
24
24
|
const fileReader = new FileReader();
|
25
25
|
fileReader.onload = (readEvent) => {
|
26
26
|
let base64 = readEvent.target.result;
|
27
|
-
base64Array.push(
|
27
|
+
base64Array.push({
|
28
|
+
file: file,
|
29
|
+
url: base64
|
30
|
+
});
|
28
31
|
if (base64Array.length === target.files.length) {
|
29
32
|
resolve(base64Array);
|
30
33
|
}
|
@@ -33,8 +36,39 @@ class FastVueMultiFile {
|
|
33
36
|
}
|
34
37
|
}
|
35
38
|
};
|
39
|
+
inputElement.onerror = reject;
|
40
|
+
inputElement.onabort = reject;
|
36
41
|
inputElement.dispatchEvent(event);
|
37
42
|
});
|
38
43
|
}
|
44
|
+
/**
|
45
|
+
* 将base64转为file对象
|
46
|
+
* @param content base64内容
|
47
|
+
* @param fileName 文件名
|
48
|
+
*/
|
49
|
+
static base64ToFile(content, fileName) {
|
50
|
+
let arr = content.split(','), mime = arr[0].match(/:(.*?);/)[1], bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
|
51
|
+
while (n--) {
|
52
|
+
u8arr[n] = bstr.charCodeAt(n);
|
53
|
+
}
|
54
|
+
const blob = new Blob([u8arr], { type: mime });
|
55
|
+
blob.lastModifiedDate = new Date();
|
56
|
+
blob.name = fileName;
|
57
|
+
return blob;
|
58
|
+
}
|
59
|
+
/**
|
60
|
+
* 将file对象转为base64
|
61
|
+
* @param file
|
62
|
+
*/
|
63
|
+
static async fileToBase64(file) {
|
64
|
+
return new Promise(function (resolved, rejected) {
|
65
|
+
const fileReader = new FileReader();
|
66
|
+
fileReader.onload = function (readEvent) {
|
67
|
+
let base64 = readEvent.target.result;
|
68
|
+
resolved(base64);
|
69
|
+
};
|
70
|
+
fileReader.readAsDataURL(file);
|
71
|
+
});
|
72
|
+
}
|
39
73
|
}
|
40
74
|
exports.FastVueMultiFile = FastVueMultiFile;
|
@@ -10,6 +10,7 @@ import { FastVueMultiFunction } from "./other/FastVueMultiFunction";
|
|
10
10
|
import { FastVueMultiElement } from "./other/FastVueMultiElement";
|
11
11
|
import { FastVueMultiWindow } from "./other/FastVueMultiWindow";
|
12
12
|
import { FastVueMultiFile } from "./other/FastVueMultiFile";
|
13
|
+
import { FastVueMultiBase64 } from "./other/FastVueMultiBase64";
|
13
14
|
/**
|
14
15
|
* FastBaseApp 手机APP功能工具类
|
15
16
|
*/
|
@@ -66,4 +67,8 @@ export declare class FastVueMultiTool {
|
|
66
67
|
* 文件选择器
|
67
68
|
*/
|
68
69
|
static File: typeof FastVueMultiFile;
|
70
|
+
/**
|
71
|
+
* base64相关操作
|
72
|
+
*/
|
73
|
+
static Base64: typeof FastVueMultiBase64;
|
69
74
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
define(["require", "exports", "tslib", "lodash", "./http/FastVueMultiHttp", "./other/FastVueMultiStore", "./vue/FastVueMultiConfig", "./http/FastVueMultiCookie", "./other/FastVueMultiClipboard", "./other/FastVueMultiDate", "./other/FastVueMultiBoolean", "./other/FastVueMultiFunction", "./other/FastVueMultiElement", "./other/FastVueMultiWindow", "./other/FastVueMultiFile"], function (require, exports, tslib_1, lodash_1, FastVueMultiHttp_1, FastVueMultiStore_1, FastVueMultiConfig_1, FastVueMultiCookie_1, FastVueMultiClipboard_1, FastVueMultiDate_1, FastVueMultiBoolean_1, FastVueMultiFunction_1, FastVueMultiElement_1, FastVueMultiWindow_1, FastVueMultiFile_1) {
|
1
|
+
define(["require", "exports", "tslib", "lodash", "./http/FastVueMultiHttp", "./other/FastVueMultiStore", "./vue/FastVueMultiConfig", "./http/FastVueMultiCookie", "./other/FastVueMultiClipboard", "./other/FastVueMultiDate", "./other/FastVueMultiBoolean", "./other/FastVueMultiFunction", "./other/FastVueMultiElement", "./other/FastVueMultiWindow", "./other/FastVueMultiFile", "./other/FastVueMultiBase64"], function (require, exports, tslib_1, lodash_1, FastVueMultiHttp_1, FastVueMultiStore_1, FastVueMultiConfig_1, FastVueMultiCookie_1, FastVueMultiClipboard_1, FastVueMultiDate_1, FastVueMultiBoolean_1, FastVueMultiFunction_1, FastVueMultiElement_1, FastVueMultiWindow_1, FastVueMultiFile_1, FastVueMultiBase64_1) {
|
2
2
|
"use strict";
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
4
|
exports.FastVueMultiTool = void 0;
|
@@ -61,6 +61,10 @@ define(["require", "exports", "tslib", "lodash", "./http/FastVueMultiHttp", "./o
|
|
61
61
|
* 文件选择器
|
62
62
|
*/
|
63
63
|
FastVueMultiTool.File = FastVueMultiFile_1.FastVueMultiFile;
|
64
|
+
/**
|
65
|
+
* base64相关操作
|
66
|
+
*/
|
67
|
+
FastVueMultiTool.Base64 = FastVueMultiBase64_1.FastVueMultiBase64;
|
64
68
|
return FastVueMultiTool;
|
65
69
|
}());
|
66
70
|
exports.FastVueMultiTool = FastVueMultiTool;
|
@@ -1,4 +1,6 @@
|
|
1
1
|
import { AxiosPromise } from "axios";
|
2
|
+
import { FastVueMultiSimpleJsonResponse } from "./FastVueMultiSimpleJsonResponse";
|
3
|
+
import { FastVueMultiSimpleRequestConfig } from "./FastVueMultiSimpleRequestConfig";
|
2
4
|
/**
|
3
5
|
* FastVueMultiHttp 网咯请求接口工具类
|
4
6
|
* @author Janesen
|
@@ -117,7 +119,7 @@ export declare namespace FastVueMultiHttp {
|
|
117
119
|
* @param config 请求配置
|
118
120
|
* @param callBack 请求接口回调函数,在使用alwaysCache和alwaysBackRequest参数为true时,必须使用回调函数接收
|
119
121
|
*/
|
120
|
-
static request(method: string, url: string, params: any, config?:
|
122
|
+
static request(method: string, url: string, params: any, config?: FastVueMultiSimpleRequestConfig, callBack?: (result: FastVueMultiSimpleJsonResponse) => void): Promise<FastVueMultiSimpleJsonResponse>;
|
121
123
|
/**
|
122
124
|
* post请求接口
|
123
125
|
* @param url 接口地址 完整的地址,例如:http://loalhost:8080/user/login
|
@@ -125,7 +127,7 @@ export declare namespace FastVueMultiHttp {
|
|
125
127
|
* @param config 请求配置
|
126
128
|
* @param callBack 请求接口回调函数,在使用alwaysCache和alwaysBackRequest参数为true时,必须使用回调函数接收
|
127
129
|
*/
|
128
|
-
static post(url: string, params: any, config?:
|
130
|
+
static post(url: string, params: any, config?: FastVueMultiSimpleRequestConfig, callBack?: (result: FastVueMultiSimpleJsonResponse) => void): Promise<FastVueMultiSimpleJsonResponse>;
|
129
131
|
/**
|
130
132
|
* get请求接口
|
131
133
|
* @param url 接口地址 完整的地址,例如:http://loalhost:8080/user/login
|
@@ -133,93 +135,6 @@ export declare namespace FastVueMultiHttp {
|
|
133
135
|
* @param config 请求配置
|
134
136
|
* @param callBack 请求接口回调函数,在使用alwaysCache和alwaysBackRequest参数为true时,必须使用回调函数接收
|
135
137
|
*/
|
136
|
-
static get(url: string, params: any, config?:
|
137
|
-
}
|
138
|
-
/**
|
139
|
-
* 常规返回数据的格式解析类 JSON:{success:true,message:"消息",data:{}}
|
140
|
-
*/
|
141
|
-
class SimpleJsonResponse {
|
142
|
-
responseData: any;
|
143
|
-
cacheData: boolean;
|
144
|
-
requestConfig: SimpleRequestConfig;
|
145
|
-
constructor(responseData: any, cacheData?: boolean);
|
146
|
-
/**
|
147
|
-
* 获取接口返回的原始数据
|
148
|
-
*/
|
149
|
-
getResponseData(): any;
|
150
|
-
/**
|
151
|
-
* 判断当前回调的数据是否是缓存的数据
|
152
|
-
*/
|
153
|
-
isCacheData(): boolean;
|
154
|
-
/**
|
155
|
-
* 判断接口是否请求成功-success
|
156
|
-
*/
|
157
|
-
isSuccess(): boolean;
|
158
|
-
/**
|
159
|
-
* 获取接口请求返回的状态值-code
|
160
|
-
*/
|
161
|
-
getCode(): number;
|
162
|
-
/**
|
163
|
-
* 获取接口请求返回的消息提示-message
|
164
|
-
*/
|
165
|
-
getMessage(): string;
|
166
|
-
/**
|
167
|
-
* 获取接口请求返回的数据-data
|
168
|
-
*/
|
169
|
-
getData(): any;
|
170
|
-
/**
|
171
|
-
* 获取接口请求返回的其他数据,例如:data_1、data_2
|
172
|
-
* @param suffixIndex 数据后缀,例如:data_1 后缀传 1
|
173
|
-
*/
|
174
|
-
getOtherData(suffixIndex: number): any;
|
175
|
-
/**
|
176
|
-
* 判断接口返回的数据data是否是分页的数据
|
177
|
-
*/
|
178
|
-
isPageData(): boolean;
|
179
|
-
/**
|
180
|
-
* 获取接口返回的数据列表,如果data是分页数据则返回分页的列表,否则返回data
|
181
|
-
*/
|
182
|
-
getList(): any[];
|
183
|
-
/**
|
184
|
-
* 获取接口列表分页数据的页数
|
185
|
-
*/
|
186
|
-
getPage(): number;
|
187
|
-
/**
|
188
|
-
* 获取接口列表分页数据的总页数
|
189
|
-
*/
|
190
|
-
getTotalPage(): number;
|
191
|
-
/**
|
192
|
-
* 获取接口列表分页数据的总行数
|
193
|
-
*/
|
194
|
-
getTotalRow(): number;
|
195
|
-
/**
|
196
|
-
* 获取接口列表分页数据的每页大小
|
197
|
-
*/
|
198
|
-
getPageSize(): number;
|
199
|
-
/**
|
200
|
-
* 是否已加载结束,当page>=totalPage 或 list 为空时,认为加载已结束
|
201
|
-
*/
|
202
|
-
isFinished(): boolean;
|
203
|
-
}
|
204
|
-
/**
|
205
|
-
* 接口请求配置类
|
206
|
-
*/
|
207
|
-
class SimpleRequestConfig {
|
208
|
-
/**
|
209
|
-
* 是否追加全局参数,默认true
|
210
|
-
*/
|
211
|
-
finalParams: boolean;
|
212
|
-
/**
|
213
|
-
* 是否缓存数据,true:检测到有当前接口的缓存数据时,将回调缓存的数据
|
214
|
-
*/
|
215
|
-
cache: boolean;
|
216
|
-
/**
|
217
|
-
* 是否总是缓存数据,true:无论是否已有缓存数据,都将请求接口并刷新当前缓存的数据,不支持then方法接收
|
218
|
-
*/
|
219
|
-
alwaysCache: boolean;
|
220
|
-
/**
|
221
|
-
* 是否总是回调接口请求返回的数据,true:如果有缓存第一次回调缓存数据,第二次回调接口返回的数据,否则值回调一次接口返回的数据,不支持then方法接收
|
222
|
-
*/
|
223
|
-
alwaysBackRequest: boolean;
|
138
|
+
static get(url: string, params: any, config?: FastVueMultiSimpleRequestConfig, callBack?: (result: FastVueMultiSimpleJsonResponse) => void): Promise<FastVueMultiSimpleJsonResponse>;
|
224
139
|
}
|
225
140
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
define(["require", "exports", "tslib", "axios", "lodash", "../vue/FastVueMultiConfig", "../other/FastVueMultiStore"], function (require, exports, tslib_1, axios_1, lodash_1, FastVueMultiConfig_1, FastVueMultiStore_1) {
|
1
|
+
define(["require", "exports", "tslib", "axios", "lodash", "../vue/FastVueMultiConfig", "../other/FastVueMultiStore", "./FastVueMultiSimpleJsonResponse", "./FastVueMultiSimpleRequestConfig"], function (require, exports, tslib_1, axios_1, lodash_1, FastVueMultiConfig_1, FastVueMultiStore_1, FastVueMultiSimpleJsonResponse_1, FastVueMultiSimpleRequestConfig_1) {
|
2
2
|
"use strict";
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
4
|
exports.FastVueMultiHttp = void 0;
|
@@ -372,7 +372,7 @@ define(["require", "exports", "tslib", "axios", "lodash", "../vue/FastVueMultiCo
|
|
372
372
|
result = FastVueMultiStore_1.FastVueMultiStore.getValue(cacheKey);
|
373
373
|
if (result.success) {
|
374
374
|
cachedData = true;
|
375
|
-
fastResponseData = new
|
375
|
+
fastResponseData = new FastVueMultiSimpleJsonResponse_1.FastVueMultiSimpleJsonResponse(JSON.parse(result.data), true);
|
376
376
|
fastResponseData.requestConfig = config;
|
377
377
|
resolved(fastResponseData);
|
378
378
|
if (callBack) {
|
@@ -384,7 +384,7 @@ define(["require", "exports", "tslib", "axios", "lodash", "../vue/FastVueMultiCo
|
|
384
384
|
}
|
385
385
|
}
|
386
386
|
if (!url) {
|
387
|
-
fastResponseData = new
|
387
|
+
fastResponseData = new FastVueMultiSimpleJsonResponse_1.FastVueMultiSimpleJsonResponse({
|
388
388
|
success: false,
|
389
389
|
message: "JS错误:请求地址不可为空!"
|
390
390
|
});
|
@@ -396,9 +396,9 @@ define(["require", "exports", "tslib", "axios", "lodash", "../vue/FastVueMultiCo
|
|
396
396
|
}
|
397
397
|
FastVueMultiHttp.Base.doRequest(method, url, params).then(function (response) {
|
398
398
|
if (!config) {
|
399
|
-
config = new
|
399
|
+
config = new FastVueMultiSimpleRequestConfig_1.FastVueMultiSimpleRequestConfig();
|
400
400
|
}
|
401
|
-
var fastResponseData = new
|
401
|
+
var fastResponseData = new FastVueMultiSimpleJsonResponse_1.FastVueMultiSimpleJsonResponse(response.data);
|
402
402
|
fastResponseData.requestConfig = config;
|
403
403
|
if (config.cache) {
|
404
404
|
if (config.alwaysBackRequest || !cachedData) {
|
@@ -457,152 +457,5 @@ define(["require", "exports", "tslib", "axios", "lodash", "../vue/FastVueMultiCo
|
|
457
457
|
return Simple;
|
458
458
|
}(Base));
|
459
459
|
FastVueMultiHttp.Simple = Simple;
|
460
|
-
/**
|
461
|
-
* 常规返回数据的格式解析类 JSON:{success:true,message:"消息",data:{}}
|
462
|
-
*/
|
463
|
-
var SimpleJsonResponse = /** @class */ (function () {
|
464
|
-
function SimpleJsonResponse(responseData, cacheData) {
|
465
|
-
this.cacheData = false;
|
466
|
-
this.requestConfig = new FastVueMultiHttp.SimpleRequestConfig();
|
467
|
-
this.responseData = responseData;
|
468
|
-
if (cacheData == undefined) {
|
469
|
-
cacheData = false;
|
470
|
-
}
|
471
|
-
this.cacheData = cacheData;
|
472
|
-
}
|
473
|
-
/**
|
474
|
-
* 获取接口返回的原始数据
|
475
|
-
*/
|
476
|
-
SimpleJsonResponse.prototype.getResponseData = function () {
|
477
|
-
return this.responseData;
|
478
|
-
};
|
479
|
-
/**
|
480
|
-
* 判断当前回调的数据是否是缓存的数据
|
481
|
-
*/
|
482
|
-
SimpleJsonResponse.prototype.isCacheData = function () {
|
483
|
-
return this.cacheData;
|
484
|
-
};
|
485
|
-
/**
|
486
|
-
* 判断接口是否请求成功-success
|
487
|
-
*/
|
488
|
-
SimpleJsonResponse.prototype.isSuccess = function () {
|
489
|
-
return this.responseData.success;
|
490
|
-
};
|
491
|
-
/**
|
492
|
-
* 获取接口请求返回的状态值-code
|
493
|
-
*/
|
494
|
-
SimpleJsonResponse.prototype.getCode = function () {
|
495
|
-
return this.responseData.code;
|
496
|
-
};
|
497
|
-
/**
|
498
|
-
* 获取接口请求返回的消息提示-message
|
499
|
-
*/
|
500
|
-
SimpleJsonResponse.prototype.getMessage = function () {
|
501
|
-
return this.responseData.message;
|
502
|
-
};
|
503
|
-
/**
|
504
|
-
* 获取接口请求返回的数据-data
|
505
|
-
*/
|
506
|
-
SimpleJsonResponse.prototype.getData = function () {
|
507
|
-
return this.responseData.data;
|
508
|
-
};
|
509
|
-
/**
|
510
|
-
* 获取接口请求返回的其他数据,例如:data_1、data_2
|
511
|
-
* @param suffixIndex 数据后缀,例如:data_1 后缀传 1
|
512
|
-
*/
|
513
|
-
SimpleJsonResponse.prototype.getOtherData = function (suffixIndex) {
|
514
|
-
return this.responseData["data_" + suffixIndex];
|
515
|
-
};
|
516
|
-
/**
|
517
|
-
* 判断接口返回的数据data是否是分页的数据
|
518
|
-
*/
|
519
|
-
SimpleJsonResponse.prototype.isPageData = function () {
|
520
|
-
if (!this.responseData.data) {
|
521
|
-
return false;
|
522
|
-
}
|
523
|
-
return this.responseData.data.hasOwnProperty("page");
|
524
|
-
};
|
525
|
-
/**
|
526
|
-
* 获取接口返回的数据列表,如果data是分页数据则返回分页的列表,否则返回data
|
527
|
-
*/
|
528
|
-
SimpleJsonResponse.prototype.getList = function () {
|
529
|
-
if (this.isPageData()) {
|
530
|
-
return this.responseData.data.list;
|
531
|
-
}
|
532
|
-
if (this.responseData.data) {
|
533
|
-
return this.responseData.data;
|
534
|
-
}
|
535
|
-
return [];
|
536
|
-
};
|
537
|
-
/**
|
538
|
-
* 获取接口列表分页数据的页数
|
539
|
-
*/
|
540
|
-
SimpleJsonResponse.prototype.getPage = function () {
|
541
|
-
if (this.isPageData()) {
|
542
|
-
return this.responseData.data.page;
|
543
|
-
}
|
544
|
-
return -1;
|
545
|
-
};
|
546
|
-
/**
|
547
|
-
* 获取接口列表分页数据的总页数
|
548
|
-
*/
|
549
|
-
SimpleJsonResponse.prototype.getTotalPage = function () {
|
550
|
-
if (this.isPageData()) {
|
551
|
-
return this.responseData.data.totalPage;
|
552
|
-
}
|
553
|
-
return -1;
|
554
|
-
};
|
555
|
-
/**
|
556
|
-
* 获取接口列表分页数据的总行数
|
557
|
-
*/
|
558
|
-
SimpleJsonResponse.prototype.getTotalRow = function () {
|
559
|
-
if (this.isPageData()) {
|
560
|
-
return this.responseData.data.totalRow;
|
561
|
-
}
|
562
|
-
return -1;
|
563
|
-
};
|
564
|
-
/**
|
565
|
-
* 获取接口列表分页数据的每页大小
|
566
|
-
*/
|
567
|
-
SimpleJsonResponse.prototype.getPageSize = function () {
|
568
|
-
if (this.isPageData()) {
|
569
|
-
return this.responseData.data.pageSize;
|
570
|
-
}
|
571
|
-
return -1;
|
572
|
-
};
|
573
|
-
/**
|
574
|
-
* 是否已加载结束,当page>=totalPage 或 list 为空时,认为加载已结束
|
575
|
-
*/
|
576
|
-
SimpleJsonResponse.prototype.isFinished = function () {
|
577
|
-
return this.getPage() >= this.getTotalPage() || this.getList().length === 0;
|
578
|
-
};
|
579
|
-
return SimpleJsonResponse;
|
580
|
-
}());
|
581
|
-
FastVueMultiHttp.SimpleJsonResponse = SimpleJsonResponse;
|
582
|
-
/**
|
583
|
-
* 接口请求配置类
|
584
|
-
*/
|
585
|
-
var SimpleRequestConfig = /** @class */ (function () {
|
586
|
-
function SimpleRequestConfig() {
|
587
|
-
/**
|
588
|
-
* 是否追加全局参数,默认true
|
589
|
-
*/
|
590
|
-
this.finalParams = true;
|
591
|
-
/**
|
592
|
-
* 是否缓存数据,true:检测到有当前接口的缓存数据时,将回调缓存的数据
|
593
|
-
*/
|
594
|
-
this.cache = false;
|
595
|
-
/**
|
596
|
-
* 是否总是缓存数据,true:无论是否已有缓存数据,都将请求接口并刷新当前缓存的数据,不支持then方法接收
|
597
|
-
*/
|
598
|
-
this.alwaysCache = false;
|
599
|
-
/**
|
600
|
-
* 是否总是回调接口请求返回的数据,true:如果有缓存第一次回调缓存数据,第二次回调接口返回的数据,否则值回调一次接口返回的数据,不支持then方法接收
|
601
|
-
*/
|
602
|
-
this.alwaysBackRequest = false;
|
603
|
-
}
|
604
|
-
return SimpleRequestConfig;
|
605
|
-
}());
|
606
|
-
FastVueMultiHttp.SimpleRequestConfig = SimpleRequestConfig;
|
607
460
|
})(FastVueMultiHttp || (exports.FastVueMultiHttp = FastVueMultiHttp = {}));
|
608
461
|
});
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import { FastVueMultiSimpleRequestConfig } from "./FastVueMultiSimpleRequestConfig";
|
2
|
+
/**
|
3
|
+
* 常规返回数据的格式解析类 JSON:{success:true,message:"消息",data:{}}
|
4
|
+
*/
|
5
|
+
export declare class FastVueMultiSimpleJsonResponse {
|
6
|
+
responseData: any;
|
7
|
+
cacheData: boolean;
|
8
|
+
requestConfig: FastVueMultiSimpleRequestConfig;
|
9
|
+
constructor(responseData: any, cacheData?: boolean);
|
10
|
+
/**
|
11
|
+
* 获取接口返回的原始数据
|
12
|
+
*/
|
13
|
+
getResponseData(): any;
|
14
|
+
/**
|
15
|
+
* 判断当前回调的数据是否是缓存的数据
|
16
|
+
*/
|
17
|
+
isCacheData(): boolean;
|
18
|
+
/**
|
19
|
+
* 判断接口是否请求成功-success
|
20
|
+
*/
|
21
|
+
isSuccess(): boolean;
|
22
|
+
/**
|
23
|
+
* 获取接口请求返回的状态值-code
|
24
|
+
*/
|
25
|
+
getCode(): number;
|
26
|
+
/**
|
27
|
+
* 获取接口请求返回的消息提示-message
|
28
|
+
*/
|
29
|
+
getMessage(): string;
|
30
|
+
/**
|
31
|
+
* 获取接口请求返回的数据-data
|
32
|
+
*/
|
33
|
+
getData(): any;
|
34
|
+
/**
|
35
|
+
* 获取接口请求返回的其他数据,例如:data_1、data_2
|
36
|
+
* @param suffixIndex 数据后缀,例如:data_1 后缀传 1
|
37
|
+
*/
|
38
|
+
getOtherData(suffixIndex: number): any;
|
39
|
+
/**
|
40
|
+
* 判断接口返回的数据data是否是分页的数据
|
41
|
+
*/
|
42
|
+
isPageData(): boolean;
|
43
|
+
/**
|
44
|
+
* 获取接口返回的数据列表,如果data是分页数据则返回分页的列表,否则返回data
|
45
|
+
*/
|
46
|
+
getList(): any[];
|
47
|
+
/**
|
48
|
+
* 获取接口列表分页数据的页数
|
49
|
+
*/
|
50
|
+
getPage(): number;
|
51
|
+
/**
|
52
|
+
* 获取接口列表分页数据的总页数
|
53
|
+
*/
|
54
|
+
getTotalPage(): number;
|
55
|
+
/**
|
56
|
+
* 获取接口列表分页数据的总行数
|
57
|
+
*/
|
58
|
+
getTotalRow(): number;
|
59
|
+
/**
|
60
|
+
* 获取接口列表分页数据的每页大小
|
61
|
+
*/
|
62
|
+
getPageSize(): number;
|
63
|
+
/**
|
64
|
+
* 是否已加载结束,当page>=totalPage 或 list 为空时,认为加载已结束
|
65
|
+
*/
|
66
|
+
isFinished(): boolean;
|
67
|
+
}
|
@@ -0,0 +1,127 @@
|
|
1
|
+
define(["require", "exports", "./FastVueMultiSimpleRequestConfig"], function (require, exports, FastVueMultiSimpleRequestConfig_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.FastVueMultiSimpleJsonResponse = void 0;
|
5
|
+
/**
|
6
|
+
* 常规返回数据的格式解析类 JSON:{success:true,message:"消息",data:{}}
|
7
|
+
*/
|
8
|
+
var FastVueMultiSimpleJsonResponse = /** @class */ (function () {
|
9
|
+
function FastVueMultiSimpleJsonResponse(responseData, cacheData) {
|
10
|
+
this.cacheData = false;
|
11
|
+
this.requestConfig = new FastVueMultiSimpleRequestConfig_1.FastVueMultiSimpleRequestConfig();
|
12
|
+
this.responseData = responseData;
|
13
|
+
if (cacheData == undefined) {
|
14
|
+
cacheData = false;
|
15
|
+
}
|
16
|
+
this.cacheData = cacheData;
|
17
|
+
}
|
18
|
+
/**
|
19
|
+
* 获取接口返回的原始数据
|
20
|
+
*/
|
21
|
+
FastVueMultiSimpleJsonResponse.prototype.getResponseData = function () {
|
22
|
+
return this.responseData;
|
23
|
+
};
|
24
|
+
/**
|
25
|
+
* 判断当前回调的数据是否是缓存的数据
|
26
|
+
*/
|
27
|
+
FastVueMultiSimpleJsonResponse.prototype.isCacheData = function () {
|
28
|
+
return this.cacheData;
|
29
|
+
};
|
30
|
+
/**
|
31
|
+
* 判断接口是否请求成功-success
|
32
|
+
*/
|
33
|
+
FastVueMultiSimpleJsonResponse.prototype.isSuccess = function () {
|
34
|
+
return this.responseData.success;
|
35
|
+
};
|
36
|
+
/**
|
37
|
+
* 获取接口请求返回的状态值-code
|
38
|
+
*/
|
39
|
+
FastVueMultiSimpleJsonResponse.prototype.getCode = function () {
|
40
|
+
return this.responseData.code;
|
41
|
+
};
|
42
|
+
/**
|
43
|
+
* 获取接口请求返回的消息提示-message
|
44
|
+
*/
|
45
|
+
FastVueMultiSimpleJsonResponse.prototype.getMessage = function () {
|
46
|
+
return this.responseData.message;
|
47
|
+
};
|
48
|
+
/**
|
49
|
+
* 获取接口请求返回的数据-data
|
50
|
+
*/
|
51
|
+
FastVueMultiSimpleJsonResponse.prototype.getData = function () {
|
52
|
+
return this.responseData.data;
|
53
|
+
};
|
54
|
+
/**
|
55
|
+
* 获取接口请求返回的其他数据,例如:data_1、data_2
|
56
|
+
* @param suffixIndex 数据后缀,例如:data_1 后缀传 1
|
57
|
+
*/
|
58
|
+
FastVueMultiSimpleJsonResponse.prototype.getOtherData = function (suffixIndex) {
|
59
|
+
return this.responseData["data_" + suffixIndex];
|
60
|
+
};
|
61
|
+
/**
|
62
|
+
* 判断接口返回的数据data是否是分页的数据
|
63
|
+
*/
|
64
|
+
FastVueMultiSimpleJsonResponse.prototype.isPageData = function () {
|
65
|
+
if (!this.responseData.data) {
|
66
|
+
return false;
|
67
|
+
}
|
68
|
+
return this.responseData.data.hasOwnProperty("page");
|
69
|
+
};
|
70
|
+
/**
|
71
|
+
* 获取接口返回的数据列表,如果data是分页数据则返回分页的列表,否则返回data
|
72
|
+
*/
|
73
|
+
FastVueMultiSimpleJsonResponse.prototype.getList = function () {
|
74
|
+
if (this.isPageData()) {
|
75
|
+
return this.responseData.data.list;
|
76
|
+
}
|
77
|
+
if (this.responseData.data) {
|
78
|
+
return this.responseData.data;
|
79
|
+
}
|
80
|
+
return [];
|
81
|
+
};
|
82
|
+
/**
|
83
|
+
* 获取接口列表分页数据的页数
|
84
|
+
*/
|
85
|
+
FastVueMultiSimpleJsonResponse.prototype.getPage = function () {
|
86
|
+
if (this.isPageData()) {
|
87
|
+
return this.responseData.data.page;
|
88
|
+
}
|
89
|
+
return -1;
|
90
|
+
};
|
91
|
+
/**
|
92
|
+
* 获取接口列表分页数据的总页数
|
93
|
+
*/
|
94
|
+
FastVueMultiSimpleJsonResponse.prototype.getTotalPage = function () {
|
95
|
+
if (this.isPageData()) {
|
96
|
+
return this.responseData.data.totalPage;
|
97
|
+
}
|
98
|
+
return -1;
|
99
|
+
};
|
100
|
+
/**
|
101
|
+
* 获取接口列表分页数据的总行数
|
102
|
+
*/
|
103
|
+
FastVueMultiSimpleJsonResponse.prototype.getTotalRow = function () {
|
104
|
+
if (this.isPageData()) {
|
105
|
+
return this.responseData.data.totalRow;
|
106
|
+
}
|
107
|
+
return -1;
|
108
|
+
};
|
109
|
+
/**
|
110
|
+
* 获取接口列表分页数据的每页大小
|
111
|
+
*/
|
112
|
+
FastVueMultiSimpleJsonResponse.prototype.getPageSize = function () {
|
113
|
+
if (this.isPageData()) {
|
114
|
+
return this.responseData.data.pageSize;
|
115
|
+
}
|
116
|
+
return -1;
|
117
|
+
};
|
118
|
+
/**
|
119
|
+
* 是否已加载结束,当page>=totalPage 或 list 为空时,认为加载已结束
|
120
|
+
*/
|
121
|
+
FastVueMultiSimpleJsonResponse.prototype.isFinished = function () {
|
122
|
+
return this.getPage() >= this.getTotalPage() || this.getList().length === 0;
|
123
|
+
};
|
124
|
+
return FastVueMultiSimpleJsonResponse;
|
125
|
+
}());
|
126
|
+
exports.FastVueMultiSimpleJsonResponse = FastVueMultiSimpleJsonResponse;
|
127
|
+
});
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/**
|
2
|
+
* 接口请求配置类
|
3
|
+
*/
|
4
|
+
export declare class FastVueMultiSimpleRequestConfig {
|
5
|
+
/**
|
6
|
+
* 是否追加全局参数,默认true
|
7
|
+
*/
|
8
|
+
finalParams: boolean;
|
9
|
+
/**
|
10
|
+
* 是否缓存数据,true:检测到有当前接口的缓存数据时,将回调缓存的数据
|
11
|
+
*/
|
12
|
+
cache: boolean;
|
13
|
+
/**
|
14
|
+
* 是否总是缓存数据,true:无论是否已有缓存数据,都将请求接口并刷新当前缓存的数据,不支持then方法接收
|
15
|
+
*/
|
16
|
+
alwaysCache: boolean;
|
17
|
+
/**
|
18
|
+
* 是否总是回调接口请求返回的数据,true:如果有缓存第一次回调缓存数据,第二次回调接口返回的数据,否则值回调一次接口返回的数据,不支持then方法接收
|
19
|
+
*/
|
20
|
+
alwaysBackRequest: boolean;
|
21
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
define(["require", "exports"], function (require, exports) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.FastVueMultiSimpleRequestConfig = void 0;
|
5
|
+
/**
|
6
|
+
* 接口请求配置类
|
7
|
+
*/
|
8
|
+
var FastVueMultiSimpleRequestConfig = /** @class */ (function () {
|
9
|
+
function FastVueMultiSimpleRequestConfig() {
|
10
|
+
/**
|
11
|
+
* 是否追加全局参数,默认true
|
12
|
+
*/
|
13
|
+
this.finalParams = true;
|
14
|
+
/**
|
15
|
+
* 是否缓存数据,true:检测到有当前接口的缓存数据时,将回调缓存的数据
|
16
|
+
*/
|
17
|
+
this.cache = false;
|
18
|
+
/**
|
19
|
+
* 是否总是缓存数据,true:无论是否已有缓存数据,都将请求接口并刷新当前缓存的数据,不支持then方法接收
|
20
|
+
*/
|
21
|
+
this.alwaysCache = false;
|
22
|
+
/**
|
23
|
+
* 是否总是回调接口请求返回的数据,true:如果有缓存第一次回调缓存数据,第二次回调接口返回的数据,否则值回调一次接口返回的数据,不支持then方法接收
|
24
|
+
*/
|
25
|
+
this.alwaysBackRequest = false;
|
26
|
+
}
|
27
|
+
return FastVueMultiSimpleRequestConfig;
|
28
|
+
}());
|
29
|
+
exports.FastVueMultiSimpleRequestConfig = FastVueMultiSimpleRequestConfig;
|
30
|
+
});
|
package/dist/esm/index.d.ts
CHANGED
@@ -1,2 +1,4 @@
|
|
1
1
|
import { FastVueMultiTool } from "./FastVueMultiTool";
|
2
|
-
|
2
|
+
import { FastVueMultiSimpleJsonResponse } from "./http/FastVueMultiSimpleJsonResponse";
|
3
|
+
import { FastVueMultiSimpleRequestConfig } from "./http/FastVueMultiSimpleRequestConfig";
|
4
|
+
export { FastVueMultiTool, FastVueMultiSimpleJsonResponse, FastVueMultiSimpleRequestConfig };
|
package/dist/esm/index.js
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
define(["require", "exports", "./FastVueMultiTool"], function (require, exports, FastVueMultiTool_1) {
|
1
|
+
define(["require", "exports", "./FastVueMultiTool", "./http/FastVueMultiSimpleJsonResponse", "./http/FastVueMultiSimpleRequestConfig"], function (require, exports, FastVueMultiTool_1, FastVueMultiSimpleJsonResponse_1, FastVueMultiSimpleRequestConfig_1) {
|
2
2
|
"use strict";
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.FastVueMultiTool = void 0;
|
4
|
+
exports.FastVueMultiSimpleRequestConfig = exports.FastVueMultiSimpleJsonResponse = exports.FastVueMultiTool = void 0;
|
5
5
|
Object.defineProperty(exports, "FastVueMultiTool", { enumerable: true, get: function () { return FastVueMultiTool_1.FastVueMultiTool; } });
|
6
|
+
Object.defineProperty(exports, "FastVueMultiSimpleJsonResponse", { enumerable: true, get: function () { return FastVueMultiSimpleJsonResponse_1.FastVueMultiSimpleJsonResponse; } });
|
7
|
+
Object.defineProperty(exports, "FastVueMultiSimpleRequestConfig", { enumerable: true, get: function () { return FastVueMultiSimpleRequestConfig_1.FastVueMultiSimpleRequestConfig; } });
|
6
8
|
});
|