mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-21 02:36:39 +08:00
opt: add image upload support for md-editor-3
This commit is contained in:
parent
437632f859
commit
9960a31485
@ -381,8 +381,26 @@ const uploadImg = (file) => {
|
||||
},
|
||||
});
|
||||
};
|
||||
const onUploadImg = (files) => {
|
||||
console.log(files);
|
||||
|
||||
// 编辑期文件上传处理
|
||||
const onUploadImg = (files, callback) => {
|
||||
Promise.all(
|
||||
files.map((file) => {
|
||||
return new Promise((rev, rej) => {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file, file.name);
|
||||
// 执行上传操作
|
||||
httpPost('/api/upload', formData).then((res) => rev(res)).catch((error) => rej(error));
|
||||
});
|
||||
})
|
||||
).then(res => {
|
||||
ElMessage.success({message: "上传成功", duration: 500})
|
||||
callback(res.map((item) => item.data.url));
|
||||
}).catch(e => {
|
||||
ElMessage.error('图片上传失败:' + e.message)
|
||||
})
|
||||
|
||||
|
||||
};
|
||||
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user