@whitesev/utils 1.6.1 → 1.7.0

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.
@@ -1568,11 +1568,13 @@ System.register('Utils', [], (function (exports) {
1568
1568
  * @private
1569
1569
  */
1570
1570
  beforeRequestCallBack(details) {
1571
- if (!details.allowInterceptConfig) {
1572
- return details;
1573
- }
1574
- if (!details.allowInterceptConfig.beforeRequest) {
1575
- return details;
1571
+ if (details.allowInterceptConfig) {
1572
+ // 首先配置得存在,不然默认允许拦截
1573
+ if (typeof details.allowInterceptConfig.beforeRequest === "boolean" &&
1574
+ !details.allowInterceptConfig.beforeRequest) {
1575
+ // 设置了禁止拦截
1576
+ return details;
1577
+ }
1576
1578
  }
1577
1579
  for (let index = 0; index < this.$config.configList.length; index++) {
1578
1580
  let item = this.$config.configList[index];
@@ -1635,11 +1637,14 @@ System.register('Utils', [], (function (exports) {
1635
1637
  * @param details 请求的配置
1636
1638
  */
1637
1639
  successResponseCallBack(response, details) {
1638
- if (!details.allowInterceptConfig) {
1639
- return details;
1640
- }
1641
- if (!details.allowInterceptConfig.afterResponseSuccess) {
1642
- return details;
1640
+ if (details.allowInterceptConfig) {
1641
+ // 首先配置得存在,不然默认允许拦截
1642
+ if (typeof details.allowInterceptConfig.afterResponseSuccess ===
1643
+ "boolean" &&
1644
+ !details.allowInterceptConfig.afterResponseSuccess) {
1645
+ // 设置了禁止拦截
1646
+ return details;
1647
+ }
1643
1648
  }
1644
1649
  for (let index = 0; index < this.$config.configList.length; index++) {
1645
1650
  let item = this.$config.configList[index];
@@ -1656,11 +1661,14 @@ System.register('Utils', [], (function (exports) {
1656
1661
  * @param data 配置
1657
1662
  */
1658
1663
  errorResponseCallBack(data) {
1659
- if (!data.details.allowInterceptConfig) {
1660
- return data;
1661
- }
1662
- if (!data.details.allowInterceptConfig.afterResponseError) {
1663
- return data;
1664
+ if (data.details.allowInterceptConfig) {
1665
+ // 首先配置得存在,不然默认允许拦截
1666
+ if (typeof data.details.allowInterceptConfig.afterResponseError ===
1667
+ "boolean" &&
1668
+ !data.details.allowInterceptConfig.afterResponseError) {
1669
+ // 设置了禁止拦截
1670
+ return data;
1671
+ }
1664
1672
  }
1665
1673
  for (let index = 0; index < this.$config.configList.length; index++) {
1666
1674
  let item = this.$config.configList[index];
@@ -3281,14 +3289,14 @@ System.register('Utils', [], (function (exports) {
3281
3289
  };
3282
3290
 
3283
3291
  class UtilsDictionary {
3284
- items = {};
3292
+ #items = {};
3285
3293
  constructor() { }
3286
3294
  /**
3287
3295
  * 检查是否有某一个键
3288
3296
  * @param key 键
3289
3297
  */
3290
3298
  has(key) {
3291
- return this.items.hasOwnProperty(key);
3299
+ return this.#items.hasOwnProperty(key);
3292
3300
  }
3293
3301
  /**
3294
3302
  * 检查已有的键中是否以xx开头
@@ -3312,7 +3320,7 @@ System.register('Utils', [], (function (exports) {
3312
3320
  let result = null;
3313
3321
  for (const keyName of allKeys) {
3314
3322
  if (keyName.startsWith(key)) {
3315
- result = this.items[keyName];
3323
+ result = this.#items[keyName];
3316
3324
  break;
3317
3325
  }
3318
3326
  }
@@ -3327,7 +3335,7 @@ System.register('Utils', [], (function (exports) {
3327
3335
  if (key === void 0) {
3328
3336
  throw new Error("Utils.Dictionary().set 参数 key 不能为空");
3329
3337
  }
3330
- this.items[key] = val;
3338
+ this.#items[key] = val;
3331
3339
  }
3332
3340
  /**
3333
3341
  * 删除某一个键
@@ -3335,7 +3343,7 @@ System.register('Utils', [], (function (exports) {
3335
3343
  */
3336
3344
  delete(key) {
3337
3345
  if (this.has(key)) {
3338
- Reflect.deleteProperty(this.items, key);
3346
+ Reflect.deleteProperty(this.#items, key);
3339
3347
  return true;
3340
3348
  }
3341
3349
  return false;
@@ -3363,8 +3371,8 @@ System.register('Utils', [], (function (exports) {
3363
3371
  * 清空字典
3364
3372
  */
3365
3373
  clear() {
3366
- this.items = void 0;
3367
- this.items = {};
3374
+ this.#items = void 0;
3375
+ this.#items = {};
3368
3376
  }
3369
3377
  /**
3370
3378
  * 获取字典的长度
@@ -3382,14 +3390,14 @@ System.register('Utils', [], (function (exports) {
3382
3390
  * 返回字典本身
3383
3391
  */
3384
3392
  getItems() {
3385
- return this.items;
3393
+ return this.#items;
3386
3394
  }
3387
3395
  /**
3388
3396
  * 合并另一个字典
3389
3397
  * @param data 需要合并的字典
3390
3398
  */
3391
3399
  concat(data) {
3392
- this.items = utils.assign(this.items, data.getItems());
3400
+ this.#items = utils.assign(this.#items, data.getItems());
3393
3401
  }
3394
3402
  forEach(callbackfn) {
3395
3403
  for (const key in this.getItems()) {