fix: failed to upload picture in the markdown editor (#401)

pull/403/head
Ryan Wang 2022-01-07 13:41:35 +08:00 committed by GitHub
parent 68c488916b
commit d3992406a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -43,14 +43,15 @@ export default {
}
},
methods: {
handleAttachmentUpload(pos, $file) {
const formdata = new FormData()
formdata.append('file', $file)
apiClient.attachment.upload(formdata).then(response => {
async handleAttachmentUpload(pos, $file) {
try {
const response = await apiClient.attachment.upload($file)
const responseObject = response.data
const HaloEditor = this.$refs.md
HaloEditor.$img2Url(pos, encodeURI(responseObject.path))
})
} catch (e) {
this.$log.error('update image error: ', e)
}
},
handleSaveDraft() {
this.$emit('onSaveDraft')