upload 1
All checks were successful
Deploy to Server / deploy (push) Successful in 28s

This commit is contained in:
jeremygan2021
2026-03-22 22:21:02 +08:00
parent 94333b61b6
commit 41d6991d5c
7 changed files with 125 additions and 66 deletions

View File

@@ -202,10 +202,39 @@ const ProjectSubmission = ({ competitionId, initialValues, onCancel, onSuccess }
<Form.Item
name="cover_image_url"
label="封面图片链接"
rules={[{ type: 'url', message: '请输入有效的URL' }]}
label="封面图片"
extra="支持上传本地图片自动转换为URL"
>
<Input prefix={<LinkOutlined />} placeholder="https://example.com/image.jpg" />
{initialValues ? (
<Upload
showUploadList={false}
accept="image/*"
beforeUpload={(file) => {
console.log('Cover image selected:', file.name);
const formData = new FormData();
formData.append('file', file);
uploadProjectFile(formData)
.then(res => {
const imageUrl = res.data.file_url_display || res.data.file_url;
form.setFieldsValue({ cover_image_url: imageUrl });
message.success('封面上传成功');
})
.catch(err => {
message.error(`上传失败: ${err.response?.data?.detail || err.message}`);
});
return Upload.LIST_IGNORE;
}}
>
<Button icon={<CloudUploadOutlined />}>选择图片</Button>
</Upload>
) : null}
<Input
placeholder="上传图片或输入URL"
style={{ marginTop: 8 }}
onChange={(e) => form.setFieldsValue({ cover_image_url: e.target.value })}
/>
</Form.Item>
{initialValues?.id && (