This commit is contained in:
@@ -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 && (
|
||||
|
||||
Reference in New Issue
Block a user