From edfa28d0f3588a9f3b8589a95e4899843cbc875f Mon Sep 17 00:00:00 2001 From: yanglbme Date: Sun, 1 Dec 2019 10:19:15 +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 | 11 +++++++++-- index.html | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/assets/scripts/editor.js b/assets/scripts/editor.js index 7306c77..6557a56 100644 --- a/assets/scripts/editor.js +++ b/assets/scripts/editor.js @@ -117,13 +117,13 @@ let app = new Vue({ const markdownImage = `![](${imageUrl})` // 将 Markdown 形式的 URL 插入编辑框光标所在位置 this.editor.replaceSelection(`\n${markdownImage}\n`, cursor); - this.refresh(); - this.$message({ showClose: true, message: '图片插入成功', type: 'success' }); + + this.refresh(); } else { // 上传失败 @@ -137,6 +137,13 @@ let app = new Vue({ failed(error, file, fileList) { console.log(error) }, + uploading(event, file, fileList) { + this.$message({ + showClose: true, + message: '图片上传中...', + type: 'info' + }); + }, // 刷新右侧预览 refresh() { this.output = this.renderWeChat(this.editor.getValue(0)); diff --git a/index.html b/index.html index a9ca8b4..1449543 100644 --- a/index.html +++ b/index.html @@ -37,7 +37,7 @@ + accept=".jpg,.jpeg,.png,.gif" :limit="1" name="smfile" :on-success="uploaded" :on-error="failed" :on-progress="uploading">