This commit is contained in:
@@ -201,7 +201,31 @@ const ProjectSubmission = ({ competitionId, initialValues, onCancel, onSuccess }
|
|||||||
onSuccess();
|
onSuccess();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('创建项目失败:', error);
|
console.error('创建项目失败:', error);
|
||||||
const errorMsg = error.response?.data?.detail || error.response?.data?.message || JSON.stringify(error.response?.data) || error.message;
|
console.error('Response data:', error.response?.data);
|
||||||
|
|
||||||
|
let errorMsg = '创建失败,请稍后重试';
|
||||||
|
|
||||||
|
if (error.response?.data) {
|
||||||
|
const data = error.response.data;
|
||||||
|
if (typeof data === 'object') {
|
||||||
|
const messages = [];
|
||||||
|
for (const [key, value] of Object.entries(data)) {
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
messages.push(`${key}: ${value.join(', ')}`);
|
||||||
|
} else {
|
||||||
|
messages.push(`${key}: ${value}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (messages.length > 0) {
|
||||||
|
errorMsg = messages.join('; ');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errorMsg = String(data);
|
||||||
|
}
|
||||||
|
} else if (error.message) {
|
||||||
|
errorMsg = error.message;
|
||||||
|
}
|
||||||
|
|
||||||
message.error(`创建失败: ${errorMsg}`);
|
message.error(`创建失败: ${errorMsg}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user