张延森 il y a 5 ans
Parent
révision
605edefb29
1 fichiers modifiés avec 11 ajouts et 2 suppressions
  1. 11
    2
      src/components/Wangedit/Wangedit.jsx

+ 11
- 2
src/components/Wangedit/Wangedit.jsx Voir le fichier

@@ -1,5 +1,6 @@
1 1
 import React from 'react';
2
-import E from 'wangeditor'
2
+import E from 'wangeditor';
3
+import { fetch, apis } from '../../utils/request';
3 4
 
4 5
 /**
5 6
  * @param {*} props
@@ -33,7 +34,15 @@ class Wangedit extends React.Component {
33 34
       }
34 35
     }
35 36
     this.editor.customConfig.zIndex = 100
36
-    this.editor.customConfig.uploadImgShowBase64 = true   
37
+    this.editor.customConfig.uploadImgMaxLength = 1
38
+    this.editor.customConfig.customUploadImg = function (files, insert) {
39
+      if (!files.length) return
40
+      
41
+      const data = new FormData()
42
+      data.append('file', files[0])
43
+
44
+      fetch(apis.image.upload)({data}).then(insert)
45
+    }
37 46
     this.editor.create()
38 47
     this.editor.txt.html(this.props.value)
39 48
   }