|
1 | 1 | <template>
|
2 | 2 | <div>
|
3 | 3 | <el-upload
|
4 |
| - :action="uploadUrl" |
| 4 | + :action="uploadFileUrl" |
5 | 5 | :before-upload="handleBeforeUpload"
|
6 | 6 | :on-success="handleUploadSuccess"
|
7 | 7 | :on-error="handleUploadError"
|
|
10 | 10 | :headers="headers"
|
11 | 11 | style="display: none"
|
12 | 12 | ref="upload"
|
13 |
| - v-if="this.type == 'url'" |
| 13 | + v-if="this.type === 'url'" |
14 | 14 | >
|
15 | 15 | </el-upload>
|
16 | 16 | <div class="editor" ref="editor" :style="styles"></div>
|
@@ -60,10 +60,8 @@ export default {
|
60 | 60 | },
|
61 | 61 | data() {
|
62 | 62 | return {
|
63 |
| - uploadUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的图片服务器地址 |
64 |
| - headers: { |
65 |
| - Authorization: "Bearer " + getAccessToken() |
66 |
| - }, |
| 63 | + uploadFileUrl: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/upload", // 请求地址 |
| 64 | + headers: { Authorization: "Bearer " + getAccessToken() }, // 设置上传的请求头部 |
67 | 65 | Quill: null,
|
68 | 66 | currentValue: "",
|
69 | 67 | options: {
|
@@ -126,7 +124,7 @@ export default {
|
126 | 124 | const editor = this.$refs.editor;
|
127 | 125 | this.Quill = new Quill(editor, this.options);
|
128 | 126 | // 如果设置了上传地址则自定义图片上传事件
|
129 |
| - if (this.type == 'url') { |
| 127 | + if (this.type === 'url') { |
130 | 128 | let toolbar = this.Quill.getModule("toolbar");
|
131 | 129 | toolbar.addHandler("image", (value) => {
|
132 | 130 | this.uploadType = "image";
|
@@ -172,11 +170,13 @@ export default {
|
172 | 170 | // 获取富文本组件实例
|
173 | 171 | let quill = this.Quill;
|
174 | 172 | // 如果上传成功
|
175 |
| - if (res.code == 200) { |
| 173 | + // edit by 芋道源码 |
| 174 | + if (res.code === 200 || res.code === 0) { |
176 | 175 | // 获取光标所在位置
|
177 | 176 | let length = quill.getSelection().index;
|
178 | 177 | // 插入图片 res.url为服务器返回的图片地址
|
179 |
| - quill.insertEmbed(length, "image", process.env.VUE_APP_BASE_API + res.fileName); |
| 178 | + // edit by 芋道源码 |
| 179 | + quill.insertEmbed(length, "image", res.data); |
180 | 180 | // 调整光标到最后
|
181 | 181 | quill.setSelection(length + 1);
|
182 | 182 | } else {
|
|
0 commit comments