zzz-pc-view 0.0.9 → 0.0.10
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/package.json +1 -1
- package/src/index.es.js +7 -5
- package/src/index.umd.js +1 -1
package/package.json
CHANGED
package/src/index.es.js
CHANGED
|
@@ -2164,10 +2164,10 @@ const useRequestUtil = (endableLoadStatus) => {
|
|
|
2164
2164
|
// 将 abort 方法添加到响应对象中
|
|
2165
2165
|
abort,
|
|
2166
2166
|
/**
|
|
2167
|
-
*
|
|
2167
|
+
* 定义一个异步方法,用于发送请求并处理响应。
|
|
2168
2168
|
* 这个方法会发送一个 HTTP 请求,并根据请求的结果调用相应的回调函数。
|
|
2169
2169
|
* @method requestData
|
|
2170
|
-
* @param {
|
|
2170
|
+
* @param {httpRequest.HttpRequestPromise} httpRequestPromise - 一个继承自 httpRequest.HttpRequestPromise 的泛型类型,表示 HTTP 请求对象。
|
|
2171
2171
|
* @param {Function} [final] - 一个可选的函数,用于在请求完成后执行最终操作。
|
|
2172
2172
|
* @returns {Promise<T extends httpRequest.HttpRequestPromise<infer R> ? R : never>} - 一个返回值为请求结果的 Promise。
|
|
2173
2173
|
* @description 这个方法会在请求开始时调用 abort 方法,以取消之前的请求。
|
|
@@ -2180,16 +2180,18 @@ const useRequestUtil = (endableLoadStatus) => {
|
|
|
2180
2180
|
abort();
|
|
2181
2181
|
setLoadStatus(true);
|
|
2182
2182
|
request = httpRequestPromise;
|
|
2183
|
+
let isAbort = false;
|
|
2183
2184
|
try {
|
|
2184
2185
|
return await request;
|
|
2185
2186
|
} catch (err) {
|
|
2187
|
+
if (err.code === ABORTED_CODE) {
|
|
2188
|
+
isAbort = true;
|
|
2189
|
+
}
|
|
2186
2190
|
throw err;
|
|
2187
2191
|
} finally {
|
|
2188
2192
|
setLoadStatus(false);
|
|
2189
|
-
|
|
2190
|
-
if (request) {
|
|
2193
|
+
if (!isAbort) {
|
|
2191
2194
|
request = void 0;
|
|
2192
|
-
isAbort = true;
|
|
2193
2195
|
}
|
|
2194
2196
|
final == null ? void 0 : final(isAbort);
|
|
2195
2197
|
}
|