Merge branch 'Wren' into shiy-login
This commit is contained in:
@@ -468,7 +468,9 @@ export async function apiRequest<T>(
|
|||||||
// 检查API返回的状态码
|
// 检查API返回的状态码
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
// 修复:支持code=0(PostgREST)和code=200(RBAC API)两种成功响应
|
// 修复:支持code=0(PostgREST)和code=200(RBAC API)两种成功响应
|
||||||
if (data && typeof data === 'object' && 'code' in data && data.code !== 0 && data.code !== 200) {
|
// 🔑 只有当 code 是数字类型时才认为是 API 状态码,字符串 code 是业务编码
|
||||||
|
if (data && typeof data === 'object' && 'code' in data &&
|
||||||
|
typeof data.code === 'number' && data.code !== 0 && data.code !== 200) {
|
||||||
const errorMessage = data.message || data.msg || '未知错误';
|
const errorMessage = data.message || data.msg || '未知错误';
|
||||||
console.error(`API请求失败: ${errorMessage} - ${url}`);
|
console.error(`API请求失败: ${errorMessage} - ${url}`);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user