Commit 3cb7aba37e2770ba1e0f1b380d5a1ff40fad731d

Authored by YunaiV
1 parent c844c7ef

v3.6.0 富文本编辑组件添加类型属性

yudao-ui-admin/src/components/Editor/index.vue
... ... @@ -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 52 default: "",
53 53 }
54 54 },
55 55 data() {
56 56 return {
  57 + uploadUrl: process.env.VUE_APP_BASE_API + "/common/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", process.env.VUE_APP_BASE_API + res.fileName);
169 170 // 调整光标到最后
170 171 quill.setSelection(length + 1);
171 172 } else {
... ...