mirror of https://github.com/halo-dev/halo-admin
Support upload image in editor.
parent
2f79471673
commit
99973c0ef2
|
@ -12,11 +12,13 @@
|
|||
</div>
|
||||
<div id="editor">
|
||||
<mavon-editor
|
||||
ref="md"
|
||||
v-model="sheetToStage.originalContent"
|
||||
:boxShadow="false"
|
||||
:toolbars="toolbars"
|
||||
:ishljs="true"
|
||||
:autofocus="false"
|
||||
@imgAdd="pictureUploadHandle"
|
||||
/>
|
||||
</div>
|
||||
</a-col>
|
||||
|
@ -136,6 +138,7 @@ import 'mavon-editor/dist/css/index.css'
|
|||
import sheetApi from '@/api/sheet'
|
||||
import themeApi from '@/api/theme'
|
||||
import optionApi from '@/api/option'
|
||||
import attachmentApi from '@/api/attachment'
|
||||
export default {
|
||||
components: {
|
||||
mavonEditor,
|
||||
|
@ -256,6 +259,21 @@ export default {
|
|||
this.autoSaveSheet()
|
||||
}, 15000)
|
||||
}
|
||||
},
|
||||
pictureUploadHandle(pos, $file) {
|
||||
var formdata = new FormData()
|
||||
formdata.append('file', $file)
|
||||
attachmentApi.upload(formdata).then((response) => {
|
||||
var responseObject = response.data
|
||||
|
||||
if (responseObject.status === 200) {
|
||||
var MavonEditor = this.$refs.md
|
||||
MavonEditor.$img2Url(pos, responseObject.data.path)
|
||||
this.$message.success('图片上传成功')
|
||||
} else {
|
||||
this.$message.error('图片上传失败:' + responseObject.message)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,9 +116,9 @@
|
|||
{{ statusProperty.text }}
|
||||
</span>
|
||||
<span
|
||||
slot="updateTime"
|
||||
slot-scope="updateTime"
|
||||
>{{ updateTime | timeAgo }}</span>
|
||||
slot="createTime"
|
||||
slot-scope="createTime"
|
||||
>{{ createTime | timeAgo }}</span>
|
||||
|
||||
<span
|
||||
slot="action"
|
||||
|
@ -218,9 +218,9 @@ const customColumns = [
|
|||
dataIndex: 'visits'
|
||||
},
|
||||
{
|
||||
title: '更新时间',
|
||||
dataIndex: 'updateTime',
|
||||
scopedSlots: { customRender: 'updateTime' }
|
||||
title: '发布时间',
|
||||
dataIndex: 'createTime',
|
||||
scopedSlots: { customRender: 'createTime' }
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
|
|
Loading…
Reference in New Issue