From 723a870ae3f65301d3ba623e7512d12595c71a37 Mon Sep 17 00:00:00 2001 From: yanglbme Date: Sat, 30 Nov 2019 21:07:27 +0800 Subject: [PATCH] feat: update images upload feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新图片上传功能 --- assets/scripts/editor.js | 3 ++- index.html | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/assets/scripts/editor.js b/assets/scripts/editor.js index 468967c..7306c77 100644 --- a/assets/scripts/editor.js +++ b/assets/scripts/editor.js @@ -111,10 +111,11 @@ let app = new Vue({ // 图片上传结束 uploaded(response, file, fileList) { if (response.success) { - // 上传成功 + // 上传成功,获取光标 const cursor = this.editor.getCursor(); const imageUrl = response.data.url const markdownImage = `![](${imageUrl})` + // 将 Markdown 形式的 URL 插入编辑框光标所在位置 this.editor.replaceSelection(`\n${markdownImage}\n`, cursor); this.refresh(); diff --git a/index.html b/index.html index e6e0042..a9ca8b4 100644 --- a/index.html +++ b/index.html @@ -34,9 +34,10 @@
+ + headers="{'Content-Type': 'multipart/form-data'}" :show-file-list="false" :multiple="false" + accept=".jpg,.jpeg,.png,.gif" :limit="1" name="smfile" :on-success="uploaded" :on-error="failed">