mirror of https://github.com/halo-dev/halo-admin
fix: failed to upload picture in the markdown editor (#401)
parent
68c488916b
commit
d3992406a2
|
@ -43,14 +43,15 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleAttachmentUpload(pos, $file) {
|
async handleAttachmentUpload(pos, $file) {
|
||||||
const formdata = new FormData()
|
try {
|
||||||
formdata.append('file', $file)
|
const response = await apiClient.attachment.upload($file)
|
||||||
apiClient.attachment.upload(formdata).then(response => {
|
|
||||||
const responseObject = response.data
|
const responseObject = response.data
|
||||||
const HaloEditor = this.$refs.md
|
const HaloEditor = this.$refs.md
|
||||||
HaloEditor.$img2Url(pos, encodeURI(responseObject.path))
|
HaloEditor.$img2Url(pos, encodeURI(responseObject.path))
|
||||||
})
|
} catch (e) {
|
||||||
|
this.$log.error('update image error: ', e)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
handleSaveDraft() {
|
handleSaveDraft() {
|
||||||
this.$emit('onSaveDraft')
|
this.$emit('onSaveDraft')
|
||||||
|
|
Loading…
Reference in New Issue