fix: 修复上传取消功能,确保 HTTP 请求正确中止

- 在 XMLHttpRequest 中添加 signal.aborted 检查
- 修复 useSliceUpload 中的 cancelFn 闭包问题
- 确保流式上传和分片上传都能正确取消
This commit is contained in:
2026-02-04 14:51:23 +08:00
parent f381d641ab
commit 17a62cd3c2
3 changed files with 57 additions and 9 deletions

View File

@@ -92,6 +92,14 @@ class Request {
});
}
// 监听 AbortSignal 来中止请求
if (config.signal) {
config.signal.addEventListener("abort", () => {
xhr.abort();
reject(new Error("上传已取消"));
});
}
// 监听上传进度
xhr.upload.addEventListener("progress", function (event) {
if (event.lengthComputable) {