From f09e59c16c07065d512a22de22320b569165d4e7 Mon Sep 17 00:00:00 2001 From: WindowBird <13870814+windows-bird@user.noreply.gitee.com> Date: Tue, 16 Sep 2025 13:50:28 +0800 Subject: [PATCH] =?UTF-8?q?request.js=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/request.js | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/utils/request.js b/utils/request.js index 610e05c..472fa70 100644 --- a/utils/request.js +++ b/utils/request.js @@ -15,20 +15,9 @@ import { // 环境配置 const ENV_CONFIG = { - develop: { - // 开发环境 - baseUrl: "http://192.168.2.58:4502", - //baseUrl: "https://testlu.chuangtewl.com/prod-api", - appId: 1, - }, - trial: { - // 体验版 - baseUrl: "http://192.168.2.58:4502", - appId: 1, - }, release: { // 正式版 - baseUrl: "http://192.168.2.58:4502", + baseUrl: "http://192.168.2.100:4501", appId: 1, }, }; @@ -120,13 +109,11 @@ function handleResponseError(res, reject, options = {}) { title: "请求的资源不存在", action: () => {}, }, - 500: { - title: "服务器错误", - action: () => {}, - }, }; - const error = errorMap[res.statusCode] || { + console.log("response:", res); + + const error = errorMap[res.data.code] || { title: res.data?.msg || "请求失败", action: () => {}, }; @@ -194,7 +181,7 @@ export function request(options = {}) { } // 请求成功处理 - if (res.statusCode === 200) { + if (res.code === 200 || res.data.code === 200) { resolve(res.data); } else { // 处理错误响应