From 08ed184c17fe51c7683539d75efdf543ea06b709 Mon Sep 17 00:00:00 2001 From: guqing <1484563614@qq.com> Date: Mon, 15 Jul 2019 21:22:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=96=87=E7=AB=A0=E7=BC=96?= =?UTF-8?q?=E8=BE=91toolbar=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/const.js | 3 ++- src/views/post/PostEdit.vue | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/core/const.js b/src/core/const.js index c6e3e42db..67a458ba1 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -18,7 +18,8 @@ const toolbars = { trash: true, // 清空 navigation: true, // 导航目录 subfield: true, // 单双栏模式 - preview: true // 预览 + preview: true, // 预览 + imagelink: true // 图片链接 } export { toolbars } diff --git a/src/views/post/PostEdit.vue b/src/views/post/PostEdit.vue index baed7cf0a..99adad7ae 100644 --- a/src/views/post/PostEdit.vue +++ b/src/views/post/PostEdit.vue @@ -13,11 +13,13 @@
@@ -202,6 +204,7 @@ import 'mavon-editor/dist/css/index.css' import categoryApi from '@/api/category' import postApi from '@/api/post' import optionApi from '@/api/option' +import attachmentApi from '@/api/attachment' export default { components: { TagSelect, @@ -347,6 +350,21 @@ export default { this.autoSavePost() }, 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) + } + }) } } }