From e48d5ab2d8596ce6ce03cb040a3069e12b0aca95 Mon Sep 17 00:00:00 2001 From: huang <1724659546@qq.com> Date: Sat, 20 Sep 2025 17:13:30 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/http.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/http.js b/src/utils/http.js index df7eb1b0..9e24e0a5 100644 --- a/src/utils/http.js +++ b/src/utils/http.js @@ -32,8 +32,8 @@ http.interceptors.response.use( // 统一处理响应数据,检查code字段 const data = response.data; - // 如果存在code字段且不等于2000,表示请求失败 - if (data.code !== undefined && data.code !== 2000) { + // 如果存在code字段且不在2000到3000之间,表示请求失败 + if (data.code !== undefined && (data.code < 2000 || data.code >= 3000)) { // 抛出错误,包含错误信息 const error = new Error(data.message || '请求失败'); error.code = data.code; @@ -41,7 +41,7 @@ http.interceptors.response.use( return Promise.reject(error); } - // code为2000或不存在code字段时,返回数据 + // code在2000到3000之间或不存在code字段时,返回数据 return data; }, error => {