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