添加草稿
This commit is contained in:
25
management/text.md
Normal file
25
management/text.md
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
const beforeUpload: UploadProps['beforeUpload'] = (rawFile) => {
|
||||||
|
const allowTypes = ['image/jpeg', 'image/png', 'image/webp'];
|
||||||
|
if (!allowTypes.includes(rawFile.type)) {
|
||||||
|
ElMessage.error('仅支持JPG/PNG/WEBP格式的图片');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (rawFile.size / 1024 / 1024 > 5) {
|
||||||
|
ElMessage.error('图片大小不能超过5MB');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
console.log("检验成功");
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 上传成功处理
|
||||||
|
const handleUploadSuccess = (response: any, index: number) => {
|
||||||
|
console.log("上传结果:", response);
|
||||||
|
const ossUrl = response.data?.url;
|
||||||
|
if (ossUrl) {
|
||||||
|
carouselItems.value[index].imageUrl = ossUrl;
|
||||||
|
ElMessage.success(`轮播图 ${index + 1} 上传成功`);
|
||||||
|
} else {
|
||||||
|
ElMessage.error(`轮播图 ${index + 1} 上传失败`);
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user