@pisell/core 1.0.31 → 1.1.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.
package/es/app/app.d.ts CHANGED
@@ -8,8 +8,8 @@ import { MenuManager } from '../menuManager';
8
8
  import LoggerManager, { LoggerOptions } from '../logger';
9
9
  import { TasksManager } from '../tasks';
10
10
  import IndexDBManager, { DBOptions } from '../indexDB';
11
- import CMD, { CMDOptions } from "../cmd";
12
- import AWS, { AWSOptions } from "../aws";
11
+ import CMD from "../cmd";
12
+ import AWS from "../aws";
13
13
  declare global {
14
14
  interface Window {
15
15
  app: App;
@@ -22,9 +22,6 @@ export interface AppOptions {
22
22
  history?: HistoryOptions;
23
23
  storage?: StorageOptions;
24
24
  locales?: LocalesOptions;
25
- cmd?: CMDOptions;
26
- aws?: AWSOptions;
27
- getPisellos?: () => any;
28
25
  }
29
26
  declare class App {
30
27
  private static instance;
@@ -46,7 +43,7 @@ declare class App {
46
43
  post: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
47
44
  put: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
48
45
  remove: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
49
- custom: (url: string, config: import("../request").RequestSetting | undefined) => any;
46
+ custom: (url: string, config: import("../request").RequestSetting | undefined) => Promise<any>;
50
47
  setConfig: (newConfig: Partial<import("../request").RequestConfig>) => void;
51
48
  getConfig: () => import("../request").RequestConfig;
52
49
  };
@@ -69,7 +66,6 @@ declare class App {
69
66
  cmd: CMD;
70
67
  aws: AWS;
71
68
  tasksManager: TasksManager;
72
- getPisellos: any;
73
69
  dbManager: IndexDBManager | null;
74
70
  constants: {
75
71
  channel: string;
package/es/app/app.js CHANGED
@@ -67,8 +67,6 @@ var App = /*#__PURE__*/function () {
67
67
  _defineProperty(this, "aws", void 0);
68
68
  // 任务管理
69
69
  _defineProperty(this, "tasksManager", void 0);
70
- // getPisellos
71
- _defineProperty(this, "getPisellos", void 0);
72
70
  _defineProperty(this, "dbManager", null);
73
71
  _defineProperty(this, "constants", {
74
72
  channel: ""
@@ -89,7 +87,6 @@ var App = /*#__PURE__*/function () {
89
87
  this.tasksManager = new TasksManager(this);
90
88
  this.cmd = new CMD(this, options === null || options === void 0 ? void 0 : options.cmd);
91
89
  this.aws = new AWS(this, options === null || options === void 0 ? void 0 : options.aws);
92
- this.getPisellos = options === null || options === void 0 ? void 0 : options.getPisellos;
93
90
  if (options !== null && options !== void 0 && options.constants) {
94
91
  this.constants = options.constants || {};
95
92
  }
@@ -134,14 +134,19 @@ var IndexDBManager = /*#__PURE__*/function () {
134
134
  }, {
135
135
  key: "add",
136
136
  value: (function () {
137
- var _add = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(storeName, data, log) {
137
+ var _add = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(storeName, data) {
138
138
  var _this2 = this;
139
- var _this$stores$find, key, uuid;
139
+ var log,
140
+ _this$stores$find,
141
+ key,
142
+ uuid,
143
+ _args2 = arguments;
140
144
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
141
145
  while (1) switch (_context2.prev = _context2.next) {
142
146
  case 0:
147
+ log = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : true;
143
148
  if (this.useIndexDB) {
144
- _context2.next = 4;
149
+ _context2.next = 5;
145
150
  break;
146
151
  }
147
152
  key = this.getStorageKey(storeName, data[((_this$stores$find = this.stores.find(function (s) {
@@ -149,7 +154,7 @@ var IndexDBManager = /*#__PURE__*/function () {
149
154
  })) === null || _this$stores$find === void 0 ? void 0 : _this$stores$find.keyPath) || 'id']);
150
155
  this.app.storage.setStorage(key, JSON.stringify(data));
151
156
  return _context2.abrupt("return", data);
152
- case 4:
157
+ case 5:
153
158
  uuid = "[ IndexDB ] ADD: - ".concat(storeName, " - ").concat(dayjs().valueOf());
154
159
  return _context2.abrupt("return", new Promise(function (resolve, reject) {
155
160
  if (!_this2.db) {
@@ -232,13 +237,13 @@ var IndexDBManager = /*#__PURE__*/function () {
232
237
  return reject(new Error('事务被中止'));
233
238
  };
234
239
  }));
235
- case 6:
240
+ case 7:
236
241
  case "end":
237
242
  return _context2.stop();
238
243
  }
239
244
  }, _callee2, this);
240
245
  }));
241
- function add(_x, _x2, _x3) {
246
+ function add(_x, _x2) {
242
247
  return _add.apply(this, arguments);
243
248
  }
244
249
  return add;
@@ -287,7 +292,7 @@ var IndexDBManager = /*#__PURE__*/function () {
287
292
  }
288
293
  }, _callee3, this);
289
294
  }));
290
- function exists(_x4, _x5) {
295
+ function exists(_x3, _x4) {
291
296
  return _exists.apply(this, arguments);
292
297
  }
293
298
  return exists;
@@ -304,12 +309,17 @@ var IndexDBManager = /*#__PURE__*/function () {
304
309
  }, {
305
310
  key: "get",
306
311
  value: (function () {
307
- var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(storeName, key, log) {
312
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(storeName, key) {
308
313
  var _this4 = this;
309
- var uuid, storageKey, data;
314
+ var log,
315
+ uuid,
316
+ storageKey,
317
+ data,
318
+ _args4 = arguments;
310
319
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
311
320
  while (1) switch (_context4.prev = _context4.next) {
312
321
  case 0:
322
+ log = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : true;
313
323
  uuid = "[ IndexDB ] GET: - ".concat(storeName, " - ").concat(key, " - ").concat(dayjs().valueOf());
314
324
  if (log) {
315
325
  this.app.logger.addLog({
@@ -321,7 +331,7 @@ var IndexDBManager = /*#__PURE__*/function () {
321
331
  });
322
332
  }
323
333
  if (this.useIndexDB) {
324
- _context4.next = 7;
334
+ _context4.next = 8;
325
335
  break;
326
336
  }
327
337
  storageKey = this.getStorageKey(storeName, key);
@@ -330,7 +340,7 @@ var IndexDBManager = /*#__PURE__*/function () {
330
340
  data = JSON.parse(data);
331
341
  }
332
342
  return _context4.abrupt("return", data);
333
- case 7:
343
+ case 8:
334
344
  return _context4.abrupt("return", new Promise(function (resolve, reject) {
335
345
  if (!_this4.db) {
336
346
  if (log) {
@@ -418,13 +428,13 @@ var IndexDBManager = /*#__PURE__*/function () {
418
428
  reject(e);
419
429
  }
420
430
  }));
421
- case 8:
431
+ case 9:
422
432
  case "end":
423
433
  return _context4.stop();
424
434
  }
425
435
  }, _callee4, this);
426
436
  }));
427
- function get(_x6, _x7, _x8) {
437
+ function get(_x5, _x6) {
428
438
  return _get.apply(this, arguments);
429
439
  }
430
440
  return get;
@@ -441,14 +451,19 @@ var IndexDBManager = /*#__PURE__*/function () {
441
451
  }, {
442
452
  key: "update",
443
453
  value: (function () {
444
- var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(storeName, data, log) {
454
+ var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(storeName, data) {
445
455
  var _this5 = this;
446
- var _this$stores$find2, key, uuid;
456
+ var log,
457
+ _this$stores$find2,
458
+ key,
459
+ uuid,
460
+ _args5 = arguments;
447
461
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
448
462
  while (1) switch (_context5.prev = _context5.next) {
449
463
  case 0:
464
+ log = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : true;
450
465
  if (this.useIndexDB) {
451
- _context5.next = 4;
466
+ _context5.next = 5;
452
467
  break;
453
468
  }
454
469
  key = this.getStorageKey(storeName, data[((_this$stores$find2 = this.stores.find(function (s) {
@@ -456,7 +471,7 @@ var IndexDBManager = /*#__PURE__*/function () {
456
471
  })) === null || _this$stores$find2 === void 0 ? void 0 : _this$stores$find2.keyPath) || 'id']);
457
472
  this.app.storage.setStorage(key, JSON.stringify(data));
458
473
  return _context5.abrupt("return", data);
459
- case 4:
474
+ case 5:
460
475
  uuid = "[ IndexDB ] UPDATE: - ".concat(storeName, " - ").concat(dayjs().valueOf());
461
476
  if (log) {
462
477
  this.app.logger.addLog({
@@ -487,68 +502,78 @@ var IndexDBManager = /*#__PURE__*/function () {
487
502
  var store = transaction.objectStore(storeName);
488
503
  var request = store.put(data);
489
504
  request.onsuccess = function () {
490
- _this5.app.logger.addLog({
491
- type: 'info',
492
- title: uuid,
493
- metadata: {
494
- msg: '数据更新完成'
495
- }
496
- });
505
+ if (log) {
506
+ _this5.app.logger.addLog({
507
+ type: 'info',
508
+ title: uuid,
509
+ metadata: {
510
+ msg: '数据更新完成'
511
+ }
512
+ });
513
+ }
497
514
  return resolve(data);
498
515
  };
499
516
  request.onerror = function () {
500
517
  var _request$error2;
501
- _this5.app.logger.addLog({
502
- type: 'info',
503
- title: uuid,
504
- metadata: {
505
- msg: '数据更新失败'
506
- }
507
- });
518
+ if (log) {
519
+ _this5.app.logger.addLog({
520
+ type: 'info',
521
+ title: uuid,
522
+ metadata: {
523
+ msg: '数据更新失败'
524
+ }
525
+ });
526
+ }
508
527
  return reject((_request$error2 = request.error) !== null && _request$error2 !== void 0 ? _request$error2 : new Error('更新数据失败'));
509
528
  };
510
529
  transaction.oncomplete = function () {
511
- _this5.app.logger.addLog({
512
- type: 'info',
513
- title: uuid,
514
- metadata: {
515
- msg: '事务完成'
516
- }
517
- });
530
+ if (log) {
531
+ _this5.app.logger.addLog({
532
+ type: 'info',
533
+ title: uuid,
534
+ metadata: {
535
+ msg: '事务完成'
536
+ }
537
+ });
538
+ }
518
539
  return console.log('✅ 事务完成');
519
540
  };
520
541
  transaction.onabort = function (e) {
521
- _this5.app.logger.addLog({
522
- type: 'info',
523
- title: uuid,
524
- metadata: {
525
- msg: '事务被中止'
526
- }
527
- });
542
+ if (log) {
543
+ _this5.app.logger.addLog({
544
+ type: 'info',
545
+ title: uuid,
546
+ metadata: {
547
+ msg: '事务被中止'
548
+ }
549
+ });
550
+ }
528
551
  return reject(new Error('事务被中止'));
529
552
  };
530
553
  transaction.onerror = function (e) {
531
554
  var _transaction$error2;
532
- _this5.app.logger.addLog({
533
- type: 'info',
534
- title: uuid,
535
- metadata: {
536
- msg: '事务错误'
537
- }
538
- });
555
+ if (log) {
556
+ _this5.app.logger.addLog({
557
+ type: 'info',
558
+ title: uuid,
559
+ metadata: {
560
+ msg: '事务错误'
561
+ }
562
+ });
563
+ }
539
564
  return reject((_transaction$error2 = transaction.error) !== null && _transaction$error2 !== void 0 ? _transaction$error2 : new Error('事务错误'));
540
565
  };
541
566
  } catch (e) {
542
567
  reject(e);
543
568
  }
544
569
  }));
545
- case 7:
570
+ case 8:
546
571
  case "end":
547
572
  return _context5.stop();
548
573
  }
549
574
  }, _callee5, this);
550
575
  }));
551
- function update(_x9, _x10, _x11) {
576
+ function update(_x7, _x8) {
552
577
  return _update.apply(this, arguments);
553
578
  }
554
579
  return update;
@@ -598,7 +623,7 @@ var IndexDBManager = /*#__PURE__*/function () {
598
623
  }
599
624
  }, _callee6, this);
600
625
  }));
601
- function _delete(_x12, _x13) {
626
+ function _delete(_x9, _x10) {
602
627
  return _delete2.apply(this, arguments);
603
628
  }
604
629
  return _delete;
@@ -667,7 +692,7 @@ var IndexDBManager = /*#__PURE__*/function () {
667
692
  }
668
693
  }, _callee7, this);
669
694
  }));
670
- function getByIndex(_x14, _x15, _x16) {
695
+ function getByIndex(_x11, _x12, _x13) {
671
696
  return _getByIndex.apply(this, arguments);
672
697
  }
673
698
  return getByIndex;
@@ -735,7 +760,7 @@ var IndexDBManager = /*#__PURE__*/function () {
735
760
  }
736
761
  }, _callee8, this);
737
762
  }));
738
- function existsByIndex(_x17, _x18, _x19) {
763
+ function existsByIndex(_x14, _x15, _x16) {
739
764
  return _existsByIndex.apply(this, arguments);
740
765
  }
741
766
  return existsByIndex;
@@ -804,7 +829,7 @@ var IndexDBManager = /*#__PURE__*/function () {
804
829
  }
805
830
  }, _callee9, this);
806
831
  }));
807
- function getAllByIndex(_x20, _x21, _x22) {
832
+ function getAllByIndex(_x17, _x18, _x19) {
808
833
  return _getAllByIndex.apply(this, arguments);
809
834
  }
810
835
  return getAllByIndex;
@@ -855,7 +880,7 @@ var IndexDBManager = /*#__PURE__*/function () {
855
880
  }
856
881
  }, _callee10, this);
857
882
  }));
858
- function count(_x23) {
883
+ function count(_x20) {
859
884
  return _count.apply(this, arguments);
860
885
  }
861
886
  return count;
@@ -909,7 +934,7 @@ var IndexDBManager = /*#__PURE__*/function () {
909
934
  }
910
935
  }, _callee11, this);
911
936
  }));
912
- function countByIndex(_x24, _x25, _x26) {
937
+ function countByIndex(_x21, _x22, _x23) {
913
938
  return _countByIndex.apply(this, arguments);
914
939
  }
915
940
  return countByIndex;
@@ -971,7 +996,7 @@ var IndexDBManager = /*#__PURE__*/function () {
971
996
  }
972
997
  }, _callee12, this);
973
998
  }));
974
- function getAll(_x27) {
999
+ function getAll(_x24) {
975
1000
  return _getAll.apply(this, arguments);
976
1001
  }
977
1002
  return getAll;
@@ -1029,7 +1054,7 @@ var IndexDBManager = /*#__PURE__*/function () {
1029
1054
  }
1030
1055
  }, _callee13, this);
1031
1056
  }));
1032
- function clear(_x28) {
1057
+ function clear(_x25) {
1033
1058
  return _clear.apply(this, arguments);
1034
1059
  }
1035
1060
  return clear;
@@ -32,7 +32,7 @@ export declare const getCacheData: (url: string, data: any, cache: CacheProps) =
32
32
  * @return {*}
33
33
  * @Author: zhiwei.Wang
34
34
  */
35
- export declare const setCacheData: (url: string, data: any, res: any, cache?: CacheProps) => any | null;
35
+ export declare const setCacheData: (url: string, data: any, res: any, cache: CacheProps) => any | null;
36
36
  /**
37
37
  * @title: 缓存函数包装器
38
38
  * @description:
@@ -10,7 +10,6 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
10
10
  //@ts-ignore
11
11
  import md5 from 'js-md5';
12
12
  import { getConfig } from "./config";
13
- import { RequestModeENUM } from "./type";
14
13
  import { getApp } from "../app";
15
14
  // 缓存池
16
15
  var CACHES = {};
@@ -28,9 +27,8 @@ var MAX_CACHE_TIME = 7 * 60 * 60 * 1000;
28
27
  var createCacheKey = function createCacheKey(url, data, cache) {
29
28
  var _getConfig = getConfig(),
30
29
  storage = _getConfig.storage;
31
- var _data = (cache === null || cache === void 0 ? void 0 : cache.cacheKeyData) || data;
32
30
  // @ts-ignore
33
- return cache.key ? storage.createKey(cache.key) : md5("".concat(url, "_").concat(JSON.stringify(_data)));
31
+ return cache.key ? storage.createKey(cache.key) : md5("".concat(url, "_").concat(JSON.stringify(data)));
34
32
  };
35
33
 
36
34
  /**
@@ -126,26 +124,20 @@ var getCache = /*#__PURE__*/function () {
126
124
  case 0:
127
125
  _getConfig3 = getConfig(), storage = _getConfig3.storage; // 如果 当前时间 - 数据缓存时间 小于 超时时间, 则数据正常.
128
126
  if (!(cache.type === 'memory')) {
129
- _context2.next = 8;
130
- break;
131
- }
132
- if (CACHES[key]) {
133
- _context2.next = 4;
127
+ _context2.next = 6;
134
128
  break;
135
129
  }
136
- return _context2.abrupt("return", null);
137
- case 4:
138
130
  if (!getIsEffectiveTime(CACHES[key].time)) {
139
- _context2.next = 6;
131
+ _context2.next = 4;
140
132
  break;
141
133
  }
142
134
  return _context2.abrupt("return", CACHES[key].data);
143
- case 6:
144
- _context2.next = 23;
135
+ case 4:
136
+ _context2.next = 21;
145
137
  break;
146
- case 8:
138
+ case 6:
147
139
  if (!(cache.type === 'storage')) {
148
- _context2.next = 15;
140
+ _context2.next = 13;
149
141
  break;
150
142
  }
151
143
  storageDetail = storage.getStorage(key) || "";
@@ -153,35 +145,35 @@ var getCache = /*#__PURE__*/function () {
153
145
  storageDetail = JSON.parse(storageDetail);
154
146
  }
155
147
  if (!getIsEffectiveTime(storageDetail.time)) {
156
- _context2.next = 13;
148
+ _context2.next = 11;
157
149
  break;
158
150
  }
159
151
  return _context2.abrupt("return", (_storageDetail = storageDetail) === null || _storageDetail === void 0 ? void 0 : _storageDetail.data);
160
- case 13:
161
- _context2.next = 23;
152
+ case 11:
153
+ _context2.next = 21;
162
154
  break;
163
- case 15:
155
+ case 13:
164
156
  if (!(cache.type === 'indexDB')) {
165
- _context2.next = 23;
157
+ _context2.next = 21;
166
158
  break;
167
159
  }
168
160
  app = getApp();
169
161
  if (!app.dbManager) {
170
- _context2.next = 23;
162
+ _context2.next = 21;
171
163
  break;
172
164
  }
173
- _context2.next = 20;
165
+ _context2.next = 18;
174
166
  return app.dbManager.get('requests', key);
175
- case 20:
167
+ case 18:
176
168
  indexDBDetail = _context2.sent;
177
169
  if (!indexDBDetail) {
178
- _context2.next = 23;
170
+ _context2.next = 21;
179
171
  break;
180
172
  }
181
173
  return _context2.abrupt("return", indexDBDetail === null || indexDBDetail === void 0 ? void 0 : indexDBDetail.data);
182
- case 23:
174
+ case 21:
183
175
  return _context2.abrupt("return", null);
184
- case 24:
176
+ case 22:
185
177
  case "end":
186
178
  return _context2.stop();
187
179
  }
@@ -259,47 +251,11 @@ export var getCacheData = /*#__PURE__*/function () {
259
251
  * @return {*}
260
252
  * @Author: zhiwei.Wang
261
253
  */
262
- export var setCacheData = function setCacheData(url, data, res) {
263
- var cache = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
264
- type: 'memory'
265
- };
254
+ export var setCacheData = function setCacheData(url, data, res, cache) {
266
255
  // 创建缓存key
267
256
  var _key = createCacheKey(url, data, cache);
268
257
  setCache(_key, res, cache);
269
258
  };
270
- var getIsCache = function getIsCache(config) {
271
- // 没有传递缓存参数, 则不缓存
272
- if (!(config !== null && config !== void 0 && config.cache) && !(config !== null && config !== void 0 && config.useCache)) {
273
- return false;
274
- }
275
- var cache = (config === null || config === void 0 ? void 0 : config.cache) || {};
276
-
277
- // 强制本地走缓存
278
- if (cache.mode === RequestModeENUM.LOCAL) {
279
- return true;
280
- }
281
-
282
- // 强制云端不走缓存
283
- if (cache.mode === RequestModeENUM.REMOTE) {
284
- return false;
285
- }
286
-
287
- // 优先本地缓存
288
- if (cache.mode === RequestModeENUM.LOCAL_REMOTE) {
289
- return true;
290
- }
291
-
292
- // 优先使用云端, 没网使用本地
293
- if (cache.mode === RequestModeENUM.REMOTE_LOCAL) {
294
- var _getApp;
295
- // 判断是否有网络, 有网络就使用接口
296
- if ((_getApp = getApp()) !== null && _getApp !== void 0 && (_getApp = _getApp.getPlugin("network")) !== null && _getApp !== void 0 && _getApp.connected) {
297
- return false;
298
- }
299
- return true;
300
- }
301
- return true;
302
- };
303
259
 
304
260
  /**
305
261
  * @title: 缓存函数包装器
@@ -313,45 +269,37 @@ var getIsCache = function getIsCache(config) {
313
269
  */
314
270
  export var cacheFn = /*#__PURE__*/function () {
315
271
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(props, fn) {
316
- var url, data, config, isCache, cache, _data, _config$cache;
272
+ var url, data, config, _data, _config$cache;
317
273
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
318
274
  while (1) switch (_context4.prev = _context4.next) {
319
275
  case 0:
320
276
  url = props.url, data = props.data, config = props.config;
321
- isCache = getIsCache(config);
322
- if (!isCache) {
323
- _context4.next = 11;
277
+ if (!(config !== null && config !== void 0 && config.cache)) {
278
+ _context4.next = 8;
324
279
  break;
325
280
  }
326
- cache = config.cache;
327
- if (config.useCache) {
328
- cache = {
329
- type: 'memory'
330
- };
331
- }
332
- // 获取缓存数据
333
- _context4.next = 7;
334
- return getCacheData(url, data, cache);
335
- case 7:
281
+ _context4.next = 4;
282
+ return getCacheData(url, data, config.cache);
283
+ case 4:
336
284
  _data = _context4.sent;
337
285
  if (!_data) {
338
- _context4.next = 11;
286
+ _context4.next = 8;
339
287
  break;
340
288
  }
341
289
  // 如果开启更新缓存执行函数
342
290
  if ((_config$cache = config.cache) !== null && _config$cache !== void 0 && _config$cache.updateCache) {
343
291
  fn(_objectSpread(_objectSpread({}, props), {}, {
344
292
  config: _objectSpread(_objectSpread({}, props.config), {}, {
345
- cache: _objectSpread(_objectSpread({}, cache), {}, {
293
+ cache: _objectSpread(_objectSpread({}, props.config.cache), {}, {
346
294
  updateCache: false
347
295
  })
348
296
  })
349
297
  }));
350
298
  }
351
299
  return _context4.abrupt("return", _data);
352
- case 11:
300
+ case 8:
353
301
  return _context4.abrupt("return", fn(props));
354
- case 12:
302
+ case 9:
355
303
  case "end":
356
304
  return _context4.stop();
357
305
  }
@@ -5,19 +5,19 @@ export declare const createRequest: (props: RequestWrapperProps) => Promise<unkn
5
5
  * @param props
6
6
  * @returns
7
7
  */
8
- export declare const request: (props: RequestWrapperProps) => any;
8
+ export declare const request: (props: RequestWrapperProps) => Promise<any>;
9
9
  export declare const get: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
10
10
  export declare const post: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
11
11
  export declare const put: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
12
12
  export declare const remove: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
13
- export declare const custom: (url: RequestWrapperProps["url"], config: RequestWrapperProps["config"]) => any;
13
+ export declare const custom: (url: RequestWrapperProps["url"], config: RequestWrapperProps["config"]) => Promise<any>;
14
14
  export * from "./type";
15
15
  declare const _default: {
16
16
  get: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
17
17
  post: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
18
18
  put: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
19
19
  remove: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
20
- custom: (url: string, config: import("./type").RequestSetting | undefined) => any;
20
+ custom: (url: string, config: import("./type").RequestSetting | undefined) => Promise<any>;
21
21
  setConfig: (newConfig: Partial<RequestConfig>) => void;
22
22
  getConfig: () => RequestConfig;
23
23
  };
@@ -13,7 +13,6 @@ import { cacheFn } from "./cache";
13
13
  import { interceptorsRequest, interceptorsResponse, interceptorsRequestError, interceptorsResponseError, requestCallback } from "./utils";
14
14
  import axios from "axios";
15
15
  import { getConfig, setConfig } from "./config";
16
- import { getApp } from "../app";
17
16
  // 实例
18
17
  var axiosInstance = axios.create(axiosConfig);
19
18
 
@@ -60,25 +59,13 @@ export var createRequest = function createRequest(props) {
60
59
  */
61
60
  export var request = function request(props) {
62
61
  var config = props.config,
63
- url = props.url,
64
- method = props.method;
62
+ url = props.url;
65
63
  // 请求防抖
66
64
  if (config !== null && config !== void 0 && config.abort) {
67
65
  var signal = createSignal(config.abort, url);
68
66
  config.signal = signal;
69
67
  }
70
68
 
71
- // 使用os服务层
72
- if (config !== null && config !== void 0 && config.osServer) {
73
- var _app$getPisellos, _pisellos$server, _pisellos$server$hasR;
74
- var app = getApp();
75
- var pisellos = (_app$getPisellos = app.getPisellos) === null || _app$getPisellos === void 0 ? void 0 : _app$getPisellos.call(app);
76
- if (pisellos !== null && pisellos !== void 0 && pisellos.server && pisellos !== null && pisellos !== void 0 && (_pisellos$server = pisellos.server) !== null && _pisellos$server !== void 0 && (_pisellos$server$hasR = _pisellos$server.hasRoute) !== null && _pisellos$server$hasR !== void 0 && _pisellos$server$hasR.call(_pisellos$server, method, url)) {
77
- var _pisellos$server2, _pisellos$server2$han;
78
- return pisellos === null || pisellos === void 0 || (_pisellos$server2 = pisellos.server) === null || _pisellos$server2 === void 0 || (_pisellos$server2$han = _pisellos$server2.handleRoute) === null || _pisellos$server2$han === void 0 ? void 0 : _pisellos$server2$han.call(_pisellos$server2, method, url, props);
79
- }
80
- }
81
-
82
69
  // 缓存函数
83
70
  return cacheFn(props, createRequest);
84
71
  };