fix(accounts): 修复鱼翅筛选参数类型为浮点数并优化错误提示
1. 后端将 min_gold 与 max_gold 参数及 Schema 类型从 int 改为 float | None,支持小数鱼翅(如 >0 快捷筛选的 0.01); 2. 修复前端 axios 拦截器在遇到 FastAPI 422 验证错误时未展开 detail 导致弹出 [object Object] 的问题; 3. 单元测试补充验证浮点数鱼翅过滤场景。
This commit is contained in:
@@ -16,7 +16,15 @@ api.interceptors.response.use(
|
||||
localStorage.removeItem('user');
|
||||
window.location.href = '/login';
|
||||
}
|
||||
const msg = error.response?.data?.detail || error.message || '请求失败';
|
||||
const detail = error.response?.data?.detail;
|
||||
let msg = error.message || '请求失败';
|
||||
if (typeof detail === 'string') {
|
||||
msg = detail;
|
||||
} else if (Array.isArray(detail) && detail.length > 0) {
|
||||
msg = detail.map((d: any) => d?.msg || (typeof d === 'string' ? d : JSON.stringify(d))).join('; ');
|
||||
} else if (detail && typeof detail === 'object') {
|
||||
msg = JSON.stringify(detail);
|
||||
}
|
||||
return Promise.reject(new Error(msg));
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user