环境变量修改

This commit is contained in:
2026-01-13 09:38:11 +00:00
parent 41179b9c83
commit f588d1e46d
5 changed files with 59 additions and 19 deletions

View File

@@ -20,8 +20,17 @@ class WorkListAPI {
const response = await fetch(url, config);
if (!response.ok) {
const errorData = await response.json().catch(() => ({}));
throw new Error(errorData.error || `HTTP错误: ${response.status}`);
// 尝试解析错误响应
let errorMessage = `HTTP错误: ${response.status}`;
try {
const errorData = await response.json();
// 使用后端返回的详细错误信息
errorMessage = errorData.detail || errorData.error || errorMessage;
} catch (parseError) {
// 如果无法解析JSON使用默认错误消息
console.error('无法解析错误响应:', parseError);
}
throw new Error(errorMessage);
}
return await response.json();