This commit is contained in:
@@ -248,14 +248,32 @@ const ProjectSubmission = ({ competitionId, initialValues, onCancel, onSuccess }
|
||||
uploadProjectFile(formData)
|
||||
.then(res => {
|
||||
const imageUrl = res.data.file_url_display || res.data.file_url;
|
||||
updateProject(projectId, { cover_image_url: imageUrl })
|
||||
const currentValues = form.getFieldsValue();
|
||||
const updateData = {
|
||||
...currentValues,
|
||||
cover_image_url: imageUrl,
|
||||
};
|
||||
if (updateData.cover_image_url && updateData.cover_image_url.startsWith('data:')) {
|
||||
delete updateData.cover_image_url;
|
||||
}
|
||||
console.log('Updating project with:', updateData);
|
||||
updateProject(projectId, updateData)
|
||||
.then(() => {
|
||||
form.setFieldsValue({ cover_image_url: imageUrl });
|
||||
message.success('封面上传成功');
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('更新封面失败:', err);
|
||||
message.error(`更新封面失败: ${err.response?.data?.detail || err.message}`);
|
||||
const errorData = err.response?.data;
|
||||
let errorMsg = '更新失败';
|
||||
if (errorData) {
|
||||
if (typeof errorData === 'object') {
|
||||
errorMsg = Object.entries(errorData).map(([k, v]) => `${k}: ${Array.isArray(v) ? v.join(', ') : v}`).join('; ');
|
||||
} else {
|
||||
errorMsg = String(errorData);
|
||||
}
|
||||
}
|
||||
message.error(`更新封面失败: ${errorMsg}`);
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
|
||||
Reference in New Issue
Block a user