From 49d3ee271b9c1538aa4059d7593a05b37844e242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=92=83=E7=99=BD?= <18511759309@163.com> Date: Tue, 31 Aug 2021 15:10:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=A0=8F=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 46 +++++++++----- src/assets/style/iconfont.less | 6 +- .../content/components/help-doc.vue | 8 +-- src/components/footer/upload-files.vue | 2 +- .../header/components/tool-button.vue | 42 ++++++++----- src/components/header/md-header.vue | 44 +++++++------ src/main.js | 62 ++++--------------- 7 files changed, 103 insertions(+), 107 deletions(-) diff --git a/src/App.vue b/src/App.vue index bcf1948..dfc7017 100644 --- a/src/App.vue +++ b/src/App.vue @@ -17,7 +17,9 @@ :disabled="disabled" :fullScreen.sync="fullScreen" :themeOptions="themeOptions" - :uploadPercent="uploadPercent" + :uploadImgPercent="uploadImgPercent" + :uploadVideoPercent="uploadVideoPercent" + :registerTools="registerTools" @upload="handleUpload" @getFormatType="formatType = $event" @updateShowHelp="showHelp = $event" @@ -166,6 +168,11 @@ export default { type: Object, default: () => {} }, + // 自定义工具栏 + registerTools: { + type: Array, + default: () => [] + }, // 行高度 rows: { type: [Number, String], @@ -211,16 +218,25 @@ export default { uploadImgCallBack() { const _this = this; return function({ url, file: { name } }) { - const originalText = _this.text; - const selectionInfo = _this.selectionInfo; - const newText = formatText( - originalText, - selectionInfo, - "\n![img](", - `${url} "=600 #left")\n` + if (isNaN(parseInt(url))) { + const originalText = _this.text; + const selectionInfo = _this.selectionInfo; + const newText = formatText( + originalText, + selectionInfo, + "\n![img](", + `${url} "=600 #left")\n` + ); + _this.text = newText; + _this.$refs.mdUploadFile.value = ""; + _this.uploadImgPercent = 100; + } else { + _this.uploadImgPercent = parseInt(url); + } + _this.$refs["md_header" + _this.id].loading( + "img", + _this.uploadImgPercent ); - _this.text = newText; - _this.$refs.mdUploadFile.value = ""; }; }, uploadFileCallBack() { @@ -252,13 +268,13 @@ export default { ); _this.text = newText; _this.$refs.mdUploadFile.value = ""; - _this.uploadPercent = 100; + _this.uploadVideoPercent = 100; } else { - _this.uploadPercent = parseInt(url); + _this.uploadVideoPercent = parseInt(url); } _this.$refs["md_header" + _this.id].loading( "video", - _this.uploadPercent + _this.uploadVideoPercent ); }; } @@ -277,7 +293,9 @@ export default { formatType: "", htmlMinHeight: 150, showHelp: false, - uploadPercent: 0, + uploadImgPercent: 0, + uploadFlePercent: 0, + uploadVideoPercent: 0, textLength: "", userList: false, callUserList: [], diff --git a/src/assets/style/iconfont.less b/src/assets/style/iconfont.less index 1cb9bba..4f48fbe 100644 --- a/src/assets/style/iconfont.less +++ b/src/assets/style/iconfont.less @@ -47,7 +47,7 @@ content: "\eaef"; } -.icon-tupian:before { +.icon-img:before { content: "\e7ed"; } @@ -107,7 +107,7 @@ content: "\e503"; } -.icon-wenjian:before { +.icon-file:before { content: "\e607"; } @@ -119,7 +119,7 @@ content: "\e6be"; } -.icon-shipin:before { +.icon-video:before { content: "\e63c"; } .icon-biaoti:before { diff --git a/src/components/content/components/help-doc.vue b/src/components/content/components/help-doc.vue index b746dcb..7cfa97d 100644 --- a/src/components/content/components/help-doc.vue +++ b/src/components/content/components/help-doc.vue @@ -69,22 +69,22 @@ export default { { title: "图片", doc: "![alt](url)", - icon: "tupian" + icon: "img" }, { title: "图片大小", doc: '![alt](url "=300x200")', - icon: "tupian" + icon: "img" }, { title: "图片位置", doc: '![alt](url "#left")', - icon: "tupian" + icon: "img" }, { title: "图片名称", doc: '![alt](url "%title")', - icon: "tupian" + icon: "img" }, { title: "代码", diff --git a/src/components/footer/upload-files.vue b/src/components/footer/upload-files.vue index 2959fe6..8c9d91c 100644 --- a/src/components/footer/upload-files.vue +++ b/src/components/footer/upload-files.vue @@ -1,6 +1,6 @@