request.js 优化

This commit is contained in:
WindowBird 2025-09-16 13:50:28 +08:00
parent 3902e20553
commit f09e59c16c

View File

@ -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 {
// 处理错误响应