@whitesev/utils 1.5.4 → 1.5.5
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.amd.js +11 -8
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +11 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +11 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +11 -8
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +11 -8
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +11 -8
- package/dist/index.umd.js.map +1 -1
- package/dist/src/Httpx.d.ts +1 -1
- package/dist/src/Utils.d.ts +2 -3
- package/package.json +1 -1
- package/src/Httpx.ts +18 -8
package/dist/index.iife.js
CHANGED
|
@@ -1507,13 +1507,14 @@ var Utils = (function () {
|
|
|
1507
1507
|
},
|
|
1508
1508
|
/**
|
|
1509
1509
|
* 成功的回调
|
|
1510
|
-
* @param response
|
|
1510
|
+
* @param response 响应
|
|
1511
|
+
* @param details 请求的配置
|
|
1511
1512
|
*/
|
|
1512
|
-
successResponseCallBack(response) {
|
|
1513
|
+
successResponseCallBack(response, details) {
|
|
1513
1514
|
for (let index = 0; index < this.$config.configList.length; index++) {
|
|
1514
1515
|
let item = this.$config.configList[index];
|
|
1515
1516
|
if (typeof item.successFn === "function") {
|
|
1516
|
-
if (item.successFn(response) == null) {
|
|
1517
|
+
if (item.successFn(response, details) == null) {
|
|
1517
1518
|
return;
|
|
1518
1519
|
}
|
|
1519
1520
|
}
|
|
@@ -1522,7 +1523,7 @@ var Utils = (function () {
|
|
|
1522
1523
|
},
|
|
1523
1524
|
/**
|
|
1524
1525
|
* 失败的回调
|
|
1525
|
-
* @param
|
|
1526
|
+
* @param data 配置
|
|
1526
1527
|
*/
|
|
1527
1528
|
errorResponseCallBack(data) {
|
|
1528
1529
|
for (let index = 0; index < this.$config.configList.length; index++) {
|
|
@@ -1785,6 +1786,7 @@ var Utils = (function () {
|
|
|
1785
1786
|
type: "onabort",
|
|
1786
1787
|
error: new TypeError("request canceled"),
|
|
1787
1788
|
response: null,
|
|
1789
|
+
details: details,
|
|
1788
1790
|
}) == null) {
|
|
1789
1791
|
return;
|
|
1790
1792
|
}
|
|
@@ -1816,6 +1818,7 @@ var Utils = (function () {
|
|
|
1816
1818
|
type: "onerror",
|
|
1817
1819
|
error: new TypeError("request error"),
|
|
1818
1820
|
response: response,
|
|
1821
|
+
details: details,
|
|
1819
1822
|
}) == null) {
|
|
1820
1823
|
return;
|
|
1821
1824
|
}
|
|
@@ -1844,6 +1847,7 @@ var Utils = (function () {
|
|
|
1844
1847
|
type: "ontimeout",
|
|
1845
1848
|
error: new TypeError("request timeout"),
|
|
1846
1849
|
response: (argumentsList || [null])[0],
|
|
1850
|
+
details: details,
|
|
1847
1851
|
}) == null) {
|
|
1848
1852
|
return;
|
|
1849
1853
|
}
|
|
@@ -1927,8 +1931,7 @@ var Utils = (function () {
|
|
|
1927
1931
|
}
|
|
1928
1932
|
/* 状态码2xx都是成功的 */
|
|
1929
1933
|
if (Math.floor(Response.status / 100) === 2) {
|
|
1930
|
-
if (this.context.HttpxResponseHook.successResponseCallBack(Response) ==
|
|
1931
|
-
null) {
|
|
1934
|
+
if (this.context.HttpxResponseHook.successResponseCallBack(Response, details) == null) {
|
|
1932
1935
|
return;
|
|
1933
1936
|
}
|
|
1934
1937
|
resolve({
|
|
@@ -2049,7 +2052,7 @@ var Utils = (function () {
|
|
|
2049
2052
|
let responseText = "";
|
|
2050
2053
|
/** 响应xml文档 */
|
|
2051
2054
|
let responseXML = "";
|
|
2052
|
-
let arrayBuffer = await resp.arrayBuffer;
|
|
2055
|
+
let arrayBuffer = await resp.arrayBuffer();
|
|
2053
2056
|
let encoding = "utf-8";
|
|
2054
2057
|
if (resp.headers.has("Content-Type")) {
|
|
2055
2058
|
let charsetMatched = resp.headers
|
|
@@ -2060,7 +2063,7 @@ var Utils = (function () {
|
|
|
2060
2063
|
}
|
|
2061
2064
|
}
|
|
2062
2065
|
let textDecoder = new TextDecoder(encoding);
|
|
2063
|
-
responseText = textDecoder.decode(
|
|
2066
|
+
responseText = textDecoder.decode(arrayBuffer);
|
|
2064
2067
|
response = responseText;
|
|
2065
2068
|
if (details.responseType === "arraybuffer") {
|
|
2066
2069
|
response = arrayBuffer;
|