From 99973c0ef2c1b2dffd40f4ce644cb474b1e0fb9c Mon Sep 17 00:00:00 2001 From: ruibaby Date: Mon, 15 Jul 2019 23:49:53 +0800 Subject: [PATCH] Support upload image in editor. --- src/views/sheet/SheetEdit.vue | 18 ++++++++++++++++++ src/views/sheet/SheetList.vue | 12 ++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/views/sheet/SheetEdit.vue b/src/views/sheet/SheetEdit.vue index f68faf0d..c3b15246 100644 --- a/src/views/sheet/SheetEdit.vue +++ b/src/views/sheet/SheetEdit.vue @@ -12,11 +12,13 @@
@@ -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) + } + }) } } } diff --git a/src/views/sheet/SheetList.vue b/src/views/sheet/SheetList.vue index 4c33157b..dbbfde75 100644 --- a/src/views/sheet/SheetList.vue +++ b/src/views/sheet/SheetList.vue @@ -116,9 +116,9 @@ {{ statusProperty.text }} {{ updateTime | timeAgo }} + slot="createTime" + slot-scope="createTime" + >{{ createTime | timeAgo }}