fast-vue-multi-pages 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. package/README.md +63 -0
  2. package/dist/cjs/FastVueMultiTool.d.ts +60 -0
  3. package/dist/cjs/FastVueMultiTool.js +65 -0
  4. package/dist/cjs/http/FastVueMultiCookie.d.ts +18 -0
  5. package/dist/cjs/http/FastVueMultiCookie.js +30 -0
  6. package/dist/cjs/http/FastVueMultiHttp.d.ts +225 -0
  7. package/dist/cjs/http/FastVueMultiHttp.js +572 -0
  8. package/dist/cjs/index.d.ts +2 -0
  9. package/dist/cjs/index.js +5 -0
  10. package/dist/cjs/loader/FastTagBuilderLoader.d.ts +2 -0
  11. package/dist/cjs/loader/FastTagBuilderLoader.js +89 -0
  12. package/dist/cjs/other/FastVueMultiBoolean.d.ts +13 -0
  13. package/dist/cjs/other/FastVueMultiBoolean.js +56 -0
  14. package/dist/cjs/other/FastVueMultiClipboard.d.ts +21 -0
  15. package/dist/cjs/other/FastVueMultiClipboard.js +38 -0
  16. package/dist/cjs/other/FastVueMultiDate.d.ts +30 -0
  17. package/dist/cjs/other/FastVueMultiDate.js +166 -0
  18. package/dist/cjs/other/FastVueMultiElement.d.ts +46 -0
  19. package/dist/cjs/other/FastVueMultiElement.js +154 -0
  20. package/dist/cjs/other/FastVueMultiFunction.d.ts +19 -0
  21. package/dist/cjs/other/FastVueMultiFunction.js +68 -0
  22. package/dist/cjs/other/FastVueMultiStore.d.ts +13 -0
  23. package/dist/cjs/other/FastVueMultiStore.js +23 -0
  24. package/dist/cjs/other/FastVueMultiWindow.d.ts +21 -0
  25. package/dist/cjs/other/FastVueMultiWindow.js +53 -0
  26. package/dist/cjs/store/FastVueMultiStore.d.ts +13 -0
  27. package/dist/cjs/store/FastVueMultiStore.js +23 -0
  28. package/dist/cjs/vue/FastVueMultiConfig.d.ts +18 -0
  29. package/dist/cjs/vue/FastVueMultiConfig.js +43 -0
  30. package/dist/esm/FastVueMultiTool.d.ts +60 -0
  31. package/dist/esm/FastVueMultiTool.js +59 -0
  32. package/dist/esm/http/FastVueMultiCookie.d.ts +18 -0
  33. package/dist/esm/http/FastVueMultiCookie.js +34 -0
  34. package/dist/esm/http/FastVueMultiHttp.d.ts +225 -0
  35. package/dist/esm/http/FastVueMultiHttp.js +608 -0
  36. package/dist/esm/index.d.ts +2 -0
  37. package/dist/esm/index.js +6 -0
  38. package/dist/esm/loader/FastTagBuilderLoader.d.ts +2 -0
  39. package/dist/esm/loader/FastTagBuilderLoader.js +89 -0
  40. package/dist/esm/other/FastVueMultiBoolean.d.ts +13 -0
  41. package/dist/esm/other/FastVueMultiBoolean.js +60 -0
  42. package/dist/esm/other/FastVueMultiClipboard.d.ts +21 -0
  43. package/dist/esm/other/FastVueMultiClipboard.js +56 -0
  44. package/dist/esm/other/FastVueMultiDate.d.ts +30 -0
  45. package/dist/esm/other/FastVueMultiDate.js +170 -0
  46. package/dist/esm/other/FastVueMultiElement.d.ts +46 -0
  47. package/dist/esm/other/FastVueMultiElement.js +158 -0
  48. package/dist/esm/other/FastVueMultiFunction.d.ts +19 -0
  49. package/dist/esm/other/FastVueMultiFunction.js +97 -0
  50. package/dist/esm/other/FastVueMultiStore.d.ts +13 -0
  51. package/dist/esm/other/FastVueMultiStore.js +27 -0
  52. package/dist/esm/other/FastVueMultiWindow.d.ts +21 -0
  53. package/dist/esm/other/FastVueMultiWindow.js +57 -0
  54. package/dist/esm/store/FastVueMultiStore.d.ts +13 -0
  55. package/dist/esm/store/FastVueMultiStore.js +27 -0
  56. package/dist/esm/vue/FastVueMultiConfig.d.ts +18 -0
  57. package/dist/esm/vue/FastVueMultiConfig.js +48 -0
  58. package/package.json +64 -0
  59. package/vue/FastBuildOption.d.ts +241 -0
  60. package/vue/FastBuildOption.js +249 -0
  61. package/vue/FastInjectJsPlugin.d.ts +11 -0
  62. package/vue/FastInjectJsPlugin.js +101 -0
  63. package/vue/FastPages.d.ts +25 -0
  64. package/vue/FastPages.js +173 -0
  65. package/vue/FastVueMultiConfig.d.ts +18 -0
  66. package/vue/FastVueMultiConfig.js +43 -0
  67. package/vue/FastVueMultiPages.d.ts +62 -0
  68. package/vue/FastVueMultiPages.js +294 -0
  69. package/vue/index.d.ts +2 -0
  70. package/vue/index.js +5 -0
@@ -0,0 +1,572 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FastVueMultiHttp = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const axios_1 = tslib_1.__importDefault(require("axios"));
6
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
7
+ const FastVueMultiConfig_1 = require("../vue/FastVueMultiConfig");
8
+ const FastVueMultiStore_1 = require("../other/FastVueMultiStore");
9
+ /**
10
+ * FastVueMultiHttp 网咯请求接口工具类
11
+ * @author Janesen
12
+ */
13
+ var FastVueMultiHttp;
14
+ (function (FastVueMultiHttp) {
15
+ /**
16
+ * 基本的网络请求接口
17
+ */
18
+ class Base {
19
+ /**
20
+ * 获取地址栏携带的参数
21
+ * @param paramName 参数名
22
+ */
23
+ static getWindowUrlParam(paramName) {
24
+ return this.getUrlParam(window.location.href, paramName);
25
+ }
26
+ /**
27
+ * 获取地址栏携带的参数对象信息
28
+ */
29
+ static getWindowUrlInfo() {
30
+ return this.getUrlParamInfo(window.location.href);
31
+ }
32
+ /**
33
+ * 获取url的参数
34
+ * @param url 地址
35
+ * @param paramName 参数名
36
+ */
37
+ static getUrlParam(url, paramName) {
38
+ let windowUrlInfo = FastVueMultiHttp.Base.getUrlParamInfo(url);
39
+ for (let windowUrlInfoKey in windowUrlInfo) {
40
+ if (windowUrlInfoKey == paramName) {
41
+ return windowUrlInfo[windowUrlInfoKey];
42
+ }
43
+ }
44
+ return null;
45
+ }
46
+ /**
47
+ * 获取url的参数实体对象
48
+ * @param url 地址
49
+ */
50
+ static getUrlParamInfo(url) {
51
+ let urlInfo = {};
52
+ let splitArray = url.split("#")[0].split("?");
53
+ let search = splitArray[splitArray.length - 1];
54
+ let vars = search.split("&");
55
+ for (let i = 0; i < vars.length; i++) {
56
+ let pair = vars[i].split("=");
57
+ urlInfo[pair[0]] = pair[1];
58
+ }
59
+ return urlInfo;
60
+ }
61
+ /**
62
+ * 追加url参数
63
+ * @param url
64
+ * @param params
65
+ */
66
+ static appendUrlParams(url, params) {
67
+ let newUrl = url;
68
+ if (url.indexOf("?") > 0) {
69
+ newUrl = url + "&1=1";
70
+ }
71
+ else {
72
+ newUrl = url + "?1=1";
73
+ }
74
+ if (params) {
75
+ this.convertToFormData(params).forEach(function (value, key, parent) {
76
+ if (value instanceof File) {
77
+ return;
78
+ }
79
+ newUrl = newUrl + "&" + key + "=" + value;
80
+ });
81
+ }
82
+ return newUrl;
83
+ }
84
+ /**
85
+ * 合并多个FormData参数
86
+ * @param formData
87
+ */
88
+ static mergeFormData(...formData) {
89
+ const newParams = new FormData();
90
+ formData.forEach(function (item) {
91
+ if (lodash_1.default.isNull(item)) {
92
+ return true;
93
+ }
94
+ item.forEach(function (value, key, parent) {
95
+ newParams.append(key, value);
96
+ });
97
+ });
98
+ return newParams;
99
+ }
100
+ /**
101
+ * 如果是formData对象则转转换参数为object对象
102
+ * @param param
103
+ */
104
+ static convertToObject(param) {
105
+ if (param instanceof FormData) {
106
+ let newParams = {};
107
+ param.forEach(function (value, key, parent) {
108
+ newParams[key] = value;
109
+ });
110
+ return newParams;
111
+ }
112
+ return param;
113
+ }
114
+ /**
115
+ * 转换参数为FormData格式
116
+ * @param param 任意格式的参数,FormData、Object、Function
117
+ */
118
+ static convertToFormData(param) {
119
+ const newParams = new FormData();
120
+ if (param instanceof FormData) {
121
+ return param;
122
+ }
123
+ else if (lodash_1.default.isFunction(param)) {
124
+ return this.convertToFormData(param());
125
+ }
126
+ else {
127
+ for (let paramKey in param) {
128
+ if (param.hasOwnProperty(paramKey)) {
129
+ newParams.append(paramKey, param[paramKey]);
130
+ }
131
+ }
132
+ }
133
+ return newParams;
134
+ }
135
+ /**
136
+ * 合并参数并转换为FormData格式
137
+ * @param params 任意多个参数,FormData、Object、Function
138
+ */
139
+ static mergeParams(...params) {
140
+ let newParams = new FormData();
141
+ params.forEach(function (param) {
142
+ if (lodash_1.default.isNull(param)) {
143
+ return true;
144
+ }
145
+ if (lodash_1.default.isArray(param)) {
146
+ newParams = FastVueMultiHttp.Base.mergeFormData(newParams, FastVueMultiHttp.Base.mergeParamsByArray(param));
147
+ }
148
+ else {
149
+ newParams = FastVueMultiHttp.Base.mergeFormData(newParams, FastVueMultiHttp.Base.convertToFormData(param));
150
+ }
151
+ });
152
+ return newParams;
153
+ }
154
+ /**
155
+ * 将数组格式的参数合并
156
+ * @param params 数组
157
+ */
158
+ static mergeParamsByArray(params) {
159
+ let newParams = new FormData();
160
+ for (let i = 0; i < params.length; i++) {
161
+ let item = params[i];
162
+ if (lodash_1.default.isNull(item)) {
163
+ continue;
164
+ }
165
+ if (lodash_1.default.isArray(item)) {
166
+ newParams = this.mergeFormData(newParams, this.mergeParamsByArray(item));
167
+ }
168
+ else {
169
+ newParams = this.mergeFormData(newParams, this.convertToFormData(item));
170
+ }
171
+ }
172
+ return newParams;
173
+ }
174
+ /**
175
+ * 发起接口请求
176
+ * @param method 请求方法,例如,post、get
177
+ * @param url 请求地址
178
+ * @param params 请求参数
179
+ */
180
+ static doRequest(method, url, params) {
181
+ let axiosConfig = {
182
+ headers: this.getFinalHeaders(),
183
+ method: method,
184
+ url: url,
185
+ timeout: 3 * 60 * 1000
186
+ };
187
+ if (method === "post") {
188
+ if (lodash_1.default.isString(params)) {
189
+ axiosConfig.paramsSerializer = params;
190
+ }
191
+ else {
192
+ axiosConfig.data = this.convertToFormData(params);
193
+ }
194
+ }
195
+ else {
196
+ if (lodash_1.default.isString(params)) {
197
+ axiosConfig.paramsSerializer = params;
198
+ }
199
+ else {
200
+ axiosConfig.params = this.convertToObject(params);
201
+ }
202
+ }
203
+ let _request = axios_1.default.create();
204
+ _request.interceptors.request.use(function (config) {
205
+ let httpBeforeRequest = FastVueMultiConfig_1.FastVueMultiConfig.getGlobalConfig("httpBeforeRequest");
206
+ if (httpBeforeRequest) {
207
+ httpBeforeRequest(config);
208
+ }
209
+ return config;
210
+ }, function (error) {
211
+ return Promise.reject(error);
212
+ });
213
+ _request.interceptors.response.use(function (response) {
214
+ let httpAfterRequest = FastVueMultiConfig_1.FastVueMultiConfig.getGlobalConfig("httpAfterRequest");
215
+ if (httpAfterRequest) {
216
+ httpAfterRequest(response);
217
+ }
218
+ return response;
219
+ }, function (error) {
220
+ return Promise.reject(error);
221
+ });
222
+ return _request(axiosConfig);
223
+ }
224
+ /**
225
+ * 执行post请求
226
+ * @param url 请求地址
227
+ * @param params 请求参数,可为object或form data
228
+ */
229
+ static doPost(url, params) {
230
+ return this.doRequest("post", url, params);
231
+ }
232
+ /**
233
+ * 执行get请求
234
+ * @param url 请求接口地址
235
+ * @param params 请求接口参数
236
+ */
237
+ static doGet(url, params) {
238
+ return this.doRequest("get", url, params);
239
+ }
240
+ /**
241
+ * 获取请求接口的默认头信息配置
242
+ */
243
+ static getFinalHeaders() {
244
+ let justFinalHeaders = {};
245
+ if (window["FastSecurity"]) {
246
+ // @ts-ignore
247
+ justFinalHeaders["token"] = window["FastSecurity"].token();
248
+ }
249
+ let httpFinalHeaders = FastVueMultiConfig_1.FastVueMultiConfig.getGlobalConfig("httpFinalHeaders");
250
+ if (httpFinalHeaders) {
251
+ for (let dataKey in httpFinalHeaders) {
252
+ if (httpFinalHeaders[dataKey] === undefined) {
253
+ continue;
254
+ }
255
+ justFinalHeaders[dataKey] = httpFinalHeaders[dataKey];
256
+ }
257
+ }
258
+ return justFinalHeaders;
259
+ }
260
+ /**
261
+ * 设置请求头
262
+ * @param key
263
+ * @param value
264
+ */
265
+ static setFinalHeader(key, value) {
266
+ let httpFinalHeaders = FastVueMultiConfig_1.FastVueMultiConfig.getGlobalConfig("httpFinalHeaders");
267
+ if (httpFinalHeaders) {
268
+ httpFinalHeaders[key] = value;
269
+ }
270
+ }
271
+ /**
272
+ * 获取接口的全局参数,同步获取了原生APP的全局参数
273
+ */
274
+ static getFinalParams() {
275
+ let justFinalParams = {};
276
+ let finalParams = FastVueMultiConfig_1.FastVueMultiConfig.getGlobalConfig("httpFinalParams");
277
+ if (finalParams) {
278
+ for (let dataKey in finalParams) {
279
+ if (finalParams[dataKey] === undefined) {
280
+ continue;
281
+ }
282
+ justFinalParams[dataKey] = finalParams[dataKey];
283
+ }
284
+ }
285
+ return justFinalParams;
286
+ }
287
+ /**
288
+ * 设置全局请求参数
289
+ * @param key
290
+ * @param value
291
+ */
292
+ static setFinalParam(key, value) {
293
+ let finalParams = FastVueMultiConfig_1.FastVueMultiConfig.getGlobalConfig("httpFinalParams");
294
+ if (finalParams) {
295
+ finalParams[key] = value;
296
+ }
297
+ }
298
+ /**
299
+ * 构建接口请求的缓存key
300
+ * @param url 请求地址
301
+ * @param params 请求参数
302
+ */
303
+ static buildCacheKey(url, params) {
304
+ const md5 = require('md5');
305
+ if (params instanceof FormData) {
306
+ let paramObj = {};
307
+ params.forEach(function (value, key, parent) {
308
+ if (value instanceof File) {
309
+ paramObj[key] = value.name + "//" + value.size + "//" + value.type;
310
+ }
311
+ else {
312
+ paramObj[key] = value;
313
+ }
314
+ });
315
+ return md5(url + JSON.stringify(paramObj));
316
+ }
317
+ return md5(url + JSON.stringify(params));
318
+ }
319
+ }
320
+ FastVueMultiHttp.Base = Base;
321
+ // noinspection DuplicatedCode
322
+ /**
323
+ * 常规的接口请求类,返回格式要求为JSON:{success:true,message:"消息",data:{}}
324
+ */
325
+ class Simple extends Base {
326
+ /**
327
+ * 发起请求接口
328
+ * @param method 请求方法,例如:post、get
329
+ * @param url 接口地址 完整的地址,例如:http://loalhost:8080/user/login
330
+ * @param params 参数
331
+ * @param config 请求配置
332
+ * @param callBack 请求接口回调函数,在使用alwaysCache和alwaysBackRequest参数为true时,必须使用回调函数接收
333
+ */
334
+ static async request(method, url, params, config, callBack) {
335
+ return new Promise(async function (resolved, rejected) {
336
+ if (!config) {
337
+ config = {
338
+ finalParams: true
339
+ };
340
+ }
341
+ params = FastVueMultiHttp.Base.convertToFormData(params);
342
+ if (config.finalParams) {
343
+ let justFinalParams = FastVueMultiHttp.Base.getFinalParams();
344
+ for (let dataKey in justFinalParams) {
345
+ if (params.has(dataKey)) {
346
+ delete justFinalParams[dataKey];
347
+ }
348
+ }
349
+ params = FastVueMultiHttp.Base.mergeParams(justFinalParams, params);
350
+ }
351
+ let cacheKey = FastVueMultiHttp.Base.buildCacheKey(url, params);
352
+ let cachedData = false;
353
+ if (config.cache) {
354
+ let result = FastVueMultiStore_1.FastVueMultiStore.getValue(cacheKey);
355
+ if (result.success) {
356
+ cachedData = true;
357
+ let fastResponseData = new SimpleJsonResponse(JSON.parse(result.data), true);
358
+ fastResponseData.requestConfig = config;
359
+ resolved(fastResponseData);
360
+ if (callBack) {
361
+ callBack(fastResponseData);
362
+ }
363
+ if (!config.alwaysCache) {
364
+ return;
365
+ }
366
+ }
367
+ }
368
+ if (!url) {
369
+ let fastResponseData = new SimpleJsonResponse({
370
+ success: false,
371
+ message: "JS错误:请求地址不可为空!"
372
+ });
373
+ resolved(fastResponseData);
374
+ if (callBack) {
375
+ callBack(fastResponseData);
376
+ }
377
+ return;
378
+ }
379
+ FastVueMultiHttp.Base.doRequest(method, url, params).then(function (response) {
380
+ if (!config) {
381
+ config = new FastVueMultiHttp.SimpleRequestConfig();
382
+ }
383
+ let fastResponseData = new SimpleJsonResponse(response.data);
384
+ fastResponseData.requestConfig = config;
385
+ if (config.cache) {
386
+ if (config.alwaysBackRequest || !cachedData) {
387
+ resolved(fastResponseData);
388
+ if (callBack) {
389
+ callBack(fastResponseData);
390
+ }
391
+ }
392
+ FastVueMultiStore_1.FastVueMultiStore.setValue(cacheKey, JSON.stringify(response.data));
393
+ }
394
+ else {
395
+ resolved(fastResponseData);
396
+ if (callBack) {
397
+ callBack(fastResponseData);
398
+ }
399
+ }
400
+ }).catch(function (error) {
401
+ console.error(error);
402
+ rejected(error);
403
+ });
404
+ });
405
+ }
406
+ /**
407
+ * post请求接口
408
+ * @param url 接口地址 完整的地址,例如:http://loalhost:8080/user/login
409
+ * @param params 参数
410
+ * @param config 请求配置
411
+ * @param callBack 请求接口回调函数,在使用alwaysCache和alwaysBackRequest参数为true时,必须使用回调函数接收
412
+ */
413
+ static async post(url, params, config, callBack) {
414
+ return this.request("post", url, params, config, callBack);
415
+ }
416
+ /**
417
+ * get请求接口
418
+ * @param url 接口地址 完整的地址,例如:http://loalhost:8080/user/login
419
+ * @param params 参数
420
+ * @param config 请求配置
421
+ * @param callBack 请求接口回调函数,在使用alwaysCache和alwaysBackRequest参数为true时,必须使用回调函数接收
422
+ */
423
+ static async get(url, params, config, callBack) {
424
+ return this.request("get", url, params, config, callBack);
425
+ }
426
+ }
427
+ FastVueMultiHttp.Simple = Simple;
428
+ /**
429
+ * 常规返回数据的格式解析类 JSON:{success:true,message:"消息",data:{}}
430
+ */
431
+ class SimpleJsonResponse {
432
+ responseData;
433
+ cacheData = false;
434
+ requestConfig = new FastVueMultiHttp.SimpleRequestConfig();
435
+ constructor(responseData, cacheData) {
436
+ this.responseData = responseData;
437
+ if (cacheData == undefined) {
438
+ cacheData = false;
439
+ }
440
+ this.cacheData = cacheData;
441
+ }
442
+ /**
443
+ * 获取接口返回的原始数据
444
+ */
445
+ getResponseData() {
446
+ return this.responseData;
447
+ }
448
+ /**
449
+ * 判断当前回调的数据是否是缓存的数据
450
+ */
451
+ isCacheData() {
452
+ return this.cacheData;
453
+ }
454
+ /**
455
+ * 判断接口是否请求成功-success
456
+ */
457
+ isSuccess() {
458
+ return this.responseData.success;
459
+ }
460
+ /**
461
+ * 获取接口请求返回的状态值-code
462
+ */
463
+ getCode() {
464
+ return this.responseData.code;
465
+ }
466
+ /**
467
+ * 获取接口请求返回的消息提示-message
468
+ */
469
+ getMessage() {
470
+ return this.responseData.message;
471
+ }
472
+ /**
473
+ * 获取接口请求返回的数据-data
474
+ */
475
+ getData() {
476
+ return this.responseData.data;
477
+ }
478
+ /**
479
+ * 获取接口请求返回的其他数据,例如:data_1、data_2
480
+ * @param suffixIndex 数据后缀,例如:data_1 后缀传 1
481
+ */
482
+ getOtherData(suffixIndex) {
483
+ return this.responseData["data_" + suffixIndex];
484
+ }
485
+ /**
486
+ * 判断接口返回的数据data是否是分页的数据
487
+ */
488
+ isPageData() {
489
+ if (!this.responseData.data) {
490
+ return false;
491
+ }
492
+ return this.responseData.data.hasOwnProperty("page");
493
+ }
494
+ /**
495
+ * 获取接口返回的数据列表,如果data是分页数据则返回分页的列表,否则返回data
496
+ */
497
+ getList() {
498
+ if (this.isPageData()) {
499
+ return this.responseData.data.list;
500
+ }
501
+ if (this.responseData.data) {
502
+ return this.responseData.data;
503
+ }
504
+ return [];
505
+ }
506
+ /**
507
+ * 获取接口列表分页数据的页数
508
+ */
509
+ getPage() {
510
+ if (this.isPageData()) {
511
+ return this.responseData.data.page;
512
+ }
513
+ return -1;
514
+ }
515
+ /**
516
+ * 获取接口列表分页数据的总页数
517
+ */
518
+ getTotalPage() {
519
+ if (this.isPageData()) {
520
+ return this.responseData.data.totalPage;
521
+ }
522
+ return -1;
523
+ }
524
+ /**
525
+ * 获取接口列表分页数据的总行数
526
+ */
527
+ getTotalRow() {
528
+ if (this.isPageData()) {
529
+ return this.responseData.data.totalRow;
530
+ }
531
+ return -1;
532
+ }
533
+ /**
534
+ * 获取接口列表分页数据的每页大小
535
+ */
536
+ getPageSize() {
537
+ if (this.isPageData()) {
538
+ return this.responseData.data.pageSize;
539
+ }
540
+ return -1;
541
+ }
542
+ /**
543
+ * 是否已加载结束,当page>=totalPage 或 list 为空时,认为加载已结束
544
+ */
545
+ isFinished() {
546
+ return this.getPage() >= this.getTotalPage() || this.getList().length === 0;
547
+ }
548
+ }
549
+ FastVueMultiHttp.SimpleJsonResponse = SimpleJsonResponse;
550
+ /**
551
+ * 接口请求配置类
552
+ */
553
+ class SimpleRequestConfig {
554
+ /**
555
+ * 是否追加全局参数,默认true
556
+ */
557
+ finalParams = true;
558
+ /**
559
+ * 是否缓存数据,true:检测到有当前接口的缓存数据时,将回调缓存的数据
560
+ */
561
+ cache = false;
562
+ /**
563
+ * 是否总是缓存数据,true:无论是否已有缓存数据,都将请求接口并刷新当前缓存的数据,不支持then方法接收
564
+ */
565
+ alwaysCache = false;
566
+ /**
567
+ * 是否总是回调接口请求返回的数据,true:如果有缓存第一次回调缓存数据,第二次回调接口返回的数据,否则值回调一次接口返回的数据,不支持then方法接收
568
+ */
569
+ alwaysBackRequest = false;
570
+ }
571
+ FastVueMultiHttp.SimpleRequestConfig = SimpleRequestConfig;
572
+ })(FastVueMultiHttp || (exports.FastVueMultiHttp = FastVueMultiHttp = {}));
@@ -0,0 +1,2 @@
1
+ import { FastVueMultiTool } from "./FastVueMultiTool";
2
+ export { FastVueMultiTool };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FastVueMultiTool = void 0;
4
+ const FastVueMultiTool_1 = require("./FastVueMultiTool");
5
+ Object.defineProperty(exports, "FastVueMultiTool", { enumerable: true, get: function () { return FastVueMultiTool_1.FastVueMultiTool; } });
@@ -0,0 +1,2 @@
1
+ declare const htmlparser2: any;
2
+ declare const singleTag: string[];
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ const htmlparser2 = require("htmlparser2");
3
+ const singleTag = ["br", "hr", "img", "input", "param", "meta", "link", "slot"];
4
+ /**
5
+ * 标签builder插件,用来处理是否排除标签内的代码
6
+ * @author Janesen
7
+ * @param source
8
+ */
9
+ module.exports = function (source) {
10
+ //对应配置的options
11
+ // @ts-ignore
12
+ let legacyLoaderConfig = this.query;
13
+ let parseNewHtml = "";
14
+ let isBreak = false, hasResolve = false;
15
+ const tagName = legacyLoaderConfig.buildLevelTagName;
16
+ const parser = new htmlparser2.Parser({
17
+ onopentag(name, attributes) {
18
+ if (isBreak) {
19
+ return;
20
+ }
21
+ let attr = "";
22
+ let buildConfig = {
23
+ level: 1,
24
+ };
25
+ for (let attributesKey in attributes) {
26
+ let attributesValue = attributes[attributesKey];
27
+ if (attributesValue.length === 0) {
28
+ attr += " " + attributesKey;
29
+ continue;
30
+ }
31
+ if (attributesKey === "level") {
32
+ buildConfig.level = parseInt(attributesValue);
33
+ }
34
+ attr += " " + attributesKey + "=\"" + attributesValue + "\"";
35
+ }
36
+ if (name === tagName) {
37
+ hasResolve = true;
38
+ if (legacyLoaderConfig.buildLevel < buildConfig.level) {
39
+ isBreak = true;
40
+ }
41
+ }
42
+ else {
43
+ if (attr.length > 0) {
44
+ parseNewHtml += "<" + name + " " + attr + " ";
45
+ }
46
+ else {
47
+ parseNewHtml += "<" + name;
48
+ }
49
+ if (singleTag.indexOf(name) >= 0) {
50
+ parseNewHtml += "/>";
51
+ }
52
+ else {
53
+ parseNewHtml += ">";
54
+ }
55
+ }
56
+ },
57
+ ontext(text) {
58
+ if (isBreak) {
59
+ return;
60
+ }
61
+ parseNewHtml += text;
62
+ },
63
+ onclosetag(name) {
64
+ if (name === tagName) {
65
+ isBreak = false;
66
+ }
67
+ if (isBreak) {
68
+ return;
69
+ }
70
+ if (singleTag.indexOf(name) >= 0) {
71
+ return;
72
+ }
73
+ if (name === tagName) {
74
+ return;
75
+ }
76
+ parseNewHtml += "</" + name + ">";
77
+ },
78
+ }, {
79
+ recognizeSelfClosing: true,
80
+ lowerCaseTags: false,
81
+ lowerCaseAttributeNames: false
82
+ });
83
+ parser.write(source);
84
+ parser.end();
85
+ if (hasResolve) {
86
+ return parseNewHtml;
87
+ }
88
+ return source;
89
+ };
@@ -0,0 +1,13 @@
1
+ export declare class FastVueMultiBoolean {
2
+ /**
3
+ * 判断目标值是否为布尔值
4
+ * @param source
5
+ */
6
+ static isBoolean(source: any): boolean;
7
+ /**
8
+ * 转为布尔值
9
+ * @param source 目标值
10
+ * @param defaultValue 默认值,当为空或无效的布尔值时 返回
11
+ */
12
+ static parse(source: any, defaultValue?: boolean): boolean;
13
+ }