Commit 28884ee638ca84c3bde6bdd5b8e5b08a659c9d4e

Authored by YunaiV
1 parent 73fac523

mp:优化 wx-editor 图片的上传

yudao-ui-admin/src/views/mp/components/wx-editor/WxEditor.vue
1 1 <!--
2 2 - Copyright (C) 2018-2019
3 3 - All rights reserved, Designed By www.joolun.com
  4 + 芋道源码:
  5 + ① 调整 uploadData 属性,只需要传入 accountId 即可
4 6 -->
5 7 <template>
6 8 <div id="wxEditor">
... ... @@ -44,14 +46,16 @@ import { getAccessToken } from &quot;@/utils/auth&quot;;
44 46  
45 47 export default {
46 48 props: {
47   - uploadData: {
48   - type: Object
  49 + /* 公众号账号编号 */
  50 + accountId: {
  51 + type: Number,
  52 + required: true
49 53 },
50   - /*编辑器的内容*/
  54 + /* 编辑器的内容 */
51 55 value: {
52 56 type: String
53 57 },
54   - /*图片大小*/
  58 + /* 图片大小 */
55 59 maxSize: {
56 60 type: Number,
57 61 default: 4000 // kb
... ... @@ -97,6 +101,10 @@ export default {
97 101 },
98 102 actionUrl: process.env.VUE_APP_BASE_API +'/admin-api/mp/material/upload-news-image', // 这里写你要上传的图片服务器地址
99 103 headers: { Authorization: "Bearer " + getAccessToken() }, // 设置上传的请求头部
  104 + uploadData: {
  105 + "type": 'image', // TODO 芋艿:试试要不要换成 thumb
  106 + "accountId": this.accountId,
  107 + },
100 108 }
101 109 },
102 110 methods: {
... ...
yudao-ui-admin/src/views/mp/draft/index.vue
... ... @@ -117,7 +117,7 @@ SOFTWARE.
117 117 <div class="right" v-loading="addMaterialLoading" v-if="articlesAdd.length > 0">
118 118 <!--富文本编辑器组件-->
119 119 <el-row>
120   - <wx-editor v-model="articlesAdd[isActiveAddNews].content" :uploadData="uploadData"
  120 + <wx-editor v-model="articlesAdd[isActiveAddNews].content" :account-id="this.uploadData.accountId"
121 121 v-if="hackResetEditor"/>
122 122 </el-row>
123 123 <br><br><br><br>
... ... @@ -204,9 +204,7 @@ export default {
204 204 fileList: [],
205 205 uploadData: {
206 206 "type": 'image', // TODO 芋艿:试试要不要换成 thumb
207   - "title": '',
208   - "introduction": '',
209   - "accountId": 1,
  207 + // "accountId": 1,
210 208 },
211 209  
212 210 // ========== 草稿新建 or 修改 ==========
... ... @@ -495,8 +493,6 @@ export default {
495 493  
496 494 // 重置上传文件的表单
497 495 this.fileList = []
498   - this.uploadData.title = ''
499   - this.uploadData.introduction = ''
500 496  
501 497 // 设置草稿的封面字段
502 498 this.articlesAdd[this.isActiveAddNews].thumbMediaId = response.data.mediaId
... ...