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