mirror of https://github.com/halo-dev/halo-admin
Support upload image in editor.
parent
2f79471673
commit
99973c0ef2
|
@ -12,11 +12,13 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="editor">
|
<div id="editor">
|
||||||
<mavon-editor
|
<mavon-editor
|
||||||
|
ref="md"
|
||||||
v-model="sheetToStage.originalContent"
|
v-model="sheetToStage.originalContent"
|
||||||
:boxShadow="false"
|
:boxShadow="false"
|
||||||
:toolbars="toolbars"
|
:toolbars="toolbars"
|
||||||
:ishljs="true"
|
:ishljs="true"
|
||||||
:autofocus="false"
|
:autofocus="false"
|
||||||
|
@imgAdd="pictureUploadHandle"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</a-col>
|
</a-col>
|
||||||
|
@ -136,6 +138,7 @@ import 'mavon-editor/dist/css/index.css'
|
||||||
import sheetApi from '@/api/sheet'
|
import sheetApi from '@/api/sheet'
|
||||||
import themeApi from '@/api/theme'
|
import themeApi from '@/api/theme'
|
||||||
import optionApi from '@/api/option'
|
import optionApi from '@/api/option'
|
||||||
|
import attachmentApi from '@/api/attachment'
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
mavonEditor,
|
mavonEditor,
|
||||||
|
@ -256,6 +259,21 @@ export default {
|
||||||
this.autoSaveSheet()
|
this.autoSaveSheet()
|
||||||
}, 15000)
|
}, 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 }}
|
{{ statusProperty.text }}
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
slot="updateTime"
|
slot="createTime"
|
||||||
slot-scope="updateTime"
|
slot-scope="createTime"
|
||||||
>{{ updateTime | timeAgo }}</span>
|
>{{ createTime | timeAgo }}</span>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
slot="action"
|
slot="action"
|
||||||
|
@ -218,9 +218,9 @@ const customColumns = [
|
||||||
dataIndex: 'visits'
|
dataIndex: 'visits'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '更新时间',
|
title: '发布时间',
|
||||||
dataIndex: 'updateTime',
|
dataIndex: 'createTime',
|
||||||
scopedSlots: { customRender: 'updateTime' }
|
scopedSlots: { customRender: 'createTime' }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
|
|
Loading…
Reference in New Issue