From 3e856a6130b68f4724aabada550a45be127fe799 Mon Sep 17 00:00:00 2001 From: Keman Wu Date: Tue, 11 Oct 2022 11:51:54 +0800 Subject: [PATCH] =?UTF-8?q?=20=E6=94=AF=E6=8C=81=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=85=B3=E9=97=ADabort=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 通过 skipUserAbortError 和 adaptor 控制是否关闭被 abort 掉的接口请求报错. 通常情况下不应该显示错误提示. --- packages/plugin-request/src/request.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/plugin-request/src/request.ts b/packages/plugin-request/src/request.ts index 2f65d3ab..5eb4f8d3 100644 --- a/packages/plugin-request/src/request.ts +++ b/packages/plugin-request/src/request.ts @@ -166,6 +166,11 @@ const getRequestMethod = () => { } errorInfo = error.info; + // skipUserAbortError == true && showType = 0, you can close message by default, and no side effect for other errors, it's necessary for user abort requests. + if (error.name === 'AbortError' && error?.request?.options?.skipUserAbortError) { + errorInfo = errorAdaptor(error.name); + } + if (errorInfo) { const errorMessage = errorInfo?.errorMessage; const errorCode = errorInfo?.errorCode;