@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.umd.js CHANGED
@@ -1569,11 +1569,13 @@
1569
1569
  * @private
1570
1570
  */
1571
1571
  beforeRequestCallBack(details) {
1572
- if (!details.allowInterceptConfig) {
1573
- return details;
1574
- }
1575
- if (!details.allowInterceptConfig.beforeRequest) {
1576
- return details;
1572
+ if (details.allowInterceptConfig) {
1573
+ // 首先配置得存在,不然默认允许拦截
1574
+ if (typeof details.allowInterceptConfig.beforeRequest === "boolean" &&
1575
+ !details.allowInterceptConfig.beforeRequest) {
1576
+ // 设置了禁止拦截
1577
+ return details;
1578
+ }
1577
1579
  }
1578
1580
  for (let index = 0; index < this.$config.configList.length; index++) {
1579
1581
  let item = this.$config.configList[index];
@@ -1636,11 +1638,14 @@
1636
1638
  * @param details 请求的配置
1637
1639
  */
1638
1640
  successResponseCallBack(response, details) {
1639
- if (!details.allowInterceptConfig) {
1640
- return details;
1641
- }
1642
- if (!details.allowInterceptConfig.afterResponseSuccess) {
1643
- return details;
1641
+ if (details.allowInterceptConfig) {
1642
+ // 首先配置得存在,不然默认允许拦截
1643
+ if (typeof details.allowInterceptConfig.afterResponseSuccess ===
1644
+ "boolean" &&
1645
+ !details.allowInterceptConfig.afterResponseSuccess) {
1646
+ // 设置了禁止拦截
1647
+ return details;
1648
+ }
1644
1649
  }
1645
1650
  for (let index = 0; index < this.$config.configList.length; index++) {
1646
1651
  let item = this.$config.configList[index];
@@ -1657,11 +1662,14 @@
1657
1662
  * @param data 配置
1658
1663
  */
1659
1664
  errorResponseCallBack(data) {
1660
- if (!data.details.allowInterceptConfig) {
1661
- return data;
1662
- }
1663
- if (!data.details.allowInterceptConfig.afterResponseError) {
1664
- return data;
1665
+ if (data.details.allowInterceptConfig) {
1666
+ // 首先配置得存在,不然默认允许拦截
1667
+ if (typeof data.details.allowInterceptConfig.afterResponseError ===
1668
+ "boolean" &&
1669
+ !data.details.allowInterceptConfig.afterResponseError) {
1670
+ // 设置了禁止拦截
1671
+ return data;
1672
+ }
1665
1673
  }
1666
1674
  for (let index = 0; index < this.$config.configList.length; index++) {
1667
1675
  let item = this.$config.configList[index];