@whitesev/utils 1.6.0 → 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.
package/dist/index.esm.js CHANGED
@@ -1563,11 +1563,13 @@ class Httpx {
1563
1563
  * @private
1564
1564
  */
1565
1565
  beforeRequestCallBack(details) {
1566
- if (!details.allowInterceptConfig) {
1567
- return details;
1568
- }
1569
- if (!details.allowInterceptConfig.beforeRequest) {
1570
- return details;
1566
+ if (details.allowInterceptConfig) {
1567
+ // 首先配置得存在,不然默认允许拦截
1568
+ if (typeof details.allowInterceptConfig.beforeRequest === "boolean" &&
1569
+ !details.allowInterceptConfig.beforeRequest) {
1570
+ // 设置了禁止拦截
1571
+ return details;
1572
+ }
1571
1573
  }
1572
1574
  for (let index = 0; index < this.$config.configList.length; index++) {
1573
1575
  let item = this.$config.configList[index];
@@ -1630,11 +1632,14 @@ class Httpx {
1630
1632
  * @param details 请求的配置
1631
1633
  */
1632
1634
  successResponseCallBack(response, details) {
1633
- if (!details.allowInterceptConfig) {
1634
- return details;
1635
- }
1636
- if (!details.allowInterceptConfig.afterResponseSuccess) {
1637
- return details;
1635
+ if (details.allowInterceptConfig) {
1636
+ // 首先配置得存在,不然默认允许拦截
1637
+ if (typeof details.allowInterceptConfig.afterResponseSuccess ===
1638
+ "boolean" &&
1639
+ !details.allowInterceptConfig.afterResponseSuccess) {
1640
+ // 设置了禁止拦截
1641
+ return details;
1642
+ }
1638
1643
  }
1639
1644
  for (let index = 0; index < this.$config.configList.length; index++) {
1640
1645
  let item = this.$config.configList[index];
@@ -1651,11 +1656,14 @@ class Httpx {
1651
1656
  * @param data 配置
1652
1657
  */
1653
1658
  errorResponseCallBack(data) {
1654
- if (!data.details.allowInterceptConfig) {
1655
- return data;
1656
- }
1657
- if (!data.details.allowInterceptConfig.afterResponseError) {
1658
- return data;
1659
+ if (data.details.allowInterceptConfig) {
1660
+ // 首先配置得存在,不然默认允许拦截
1661
+ if (typeof data.details.allowInterceptConfig.afterResponseError ===
1662
+ "boolean" &&
1663
+ !data.details.allowInterceptConfig.afterResponseError) {
1664
+ // 设置了禁止拦截
1665
+ return data;
1666
+ }
1659
1667
  }
1660
1668
  for (let index = 0; index < this.$config.configList.length; index++) {
1661
1669
  let item = this.$config.configList[index];