正在显示
1 个修改的文件
包含
6 行增加
和
5 行删除
| @@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
| 9 | :headers="headers" | 9 | :headers="headers" |
| 10 | style="display: none" | 10 | style="display: none" |
| 11 | ref="upload" | 11 | ref="upload" |
| 12 | - v-if="this.uploadUrl" | 12 | + v-if="this.type == 'url'" |
| 13 | > | 13 | > |
| 14 | </el-upload> | 14 | </el-upload> |
| 15 | <div class="editor" ref="editor" :style="styles"></div> | 15 | <div class="editor" ref="editor" :style="styles"></div> |
| @@ -46,14 +46,15 @@ export default { | @@ -46,14 +46,15 @@ export default { | ||
| 46 | type: Boolean, | 46 | type: Boolean, |
| 47 | default: false, | 47 | default: false, |
| 48 | }, | 48 | }, |
| 49 | - /* 上传地址 */ | ||
| 50 | - uploadUrl: { | 49 | + /* 类型(base64格式、url格式) */ |
| 50 | + type: { | ||
| 51 | type: String, | 51 | type: String, |
| 52 | default: "", | 52 | default: "", |
| 53 | } | 53 | } |
| 54 | }, | 54 | }, |
| 55 | data() { | 55 | data() { |
| 56 | return { | 56 | return { |
| 57 | + uploadUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的图片服务器地址 | ||
| 57 | headers: { | 58 | headers: { |
| 58 | Authorization: "Bearer " + getToken() | 59 | Authorization: "Bearer " + getToken() |
| 59 | }, | 60 | }, |
| @@ -119,7 +120,7 @@ export default { | @@ -119,7 +120,7 @@ export default { | ||
| 119 | const editor = this.$refs.editor; | 120 | const editor = this.$refs.editor; |
| 120 | this.Quill = new Quill(editor, this.options); | 121 | this.Quill = new Quill(editor, this.options); |
| 121 | // 如果设置了上传地址则自定义图片上传事件 | 122 | // 如果设置了上传地址则自定义图片上传事件 |
| 122 | - if (this.uploadUrl) { | 123 | + if (this.type == 'url') { |
| 123 | let toolbar = this.Quill.getModule("toolbar"); | 124 | let toolbar = this.Quill.getModule("toolbar"); |
| 124 | toolbar.addHandler("image", (value) => { | 125 | toolbar.addHandler("image", (value) => { |
| 125 | this.uploadType = "image"; | 126 | this.uploadType = "image"; |
| @@ -165,7 +166,7 @@ export default { | @@ -165,7 +166,7 @@ export default { | ||
| 165 | // 获取光标所在位置 | 166 | // 获取光标所在位置 |
| 166 | let length = quill.getSelection().index; | 167 | let length = quill.getSelection().index; |
| 167 | // 插入图片 res.url为服务器返回的图片地址 | 168 | // 插入图片 res.url为服务器返回的图片地址 |
| 168 | - quill.insertEmbed(length, "image", res.url); | 169 | + quill.insertEmbed(length, "image", process.env.VUE_APP_BASE_API + res.fileName); |
| 169 | // 调整光标到最后 | 170 | // 调整光标到最后 |
| 170 | quill.setSelection(length + 1); | 171 | quill.setSelection(length + 1); |
| 171 | } else { | 172 | } else { |
-
请 注册 或 登录 后发表评论