Browse Source

image upload兼容性修改:添加limitOne适配私信

Evo 4 years ago
parent
commit
a888ebe920
2 changed files with 9 additions and 4 deletions
  1. 8
    4
      src/components/Editor/index.js
  2. 1
    0
      src/index.js

+ 8
- 4
src/components/Editor/index.js View File

174
    *  -- evo 20200223
174
    *  -- evo 20200223
175
    */
175
    */
176
   invokeFileListChange(fileList) {
176
   invokeFileListChange(fileList) {
177
-    this.props.handleChangeFileList(fileList);
177
+    const { limitOne, handleChangeFileList } = this.props;
178
+    handleChangeFileList(fileList);
178
     this.setState({ fileList });
179
     this.setState({ fileList });
179
-    if (isMobile) {
180
+    if (limitOne && isMobile) {
180
       const file = fileList[0];
181
       const file = fileList[0];
181
       if (
182
       if (
182
         file &&
183
         file &&
542
   onError: PropTypes.func,
543
   onError: PropTypes.func,
543
   maxLength: PropTypes.number,
544
   maxLength: PropTypes.number,
544
   // Enter事件相关
545
   // Enter事件相关
545
-  allowEnterSubmit: PropTypes.bool
546
+  allowEnterSubmit: PropTypes.bool,
547
+  // 私信仅允许选中一个,此处可以优化为通用的limit
548
+  limitOne: PropTypes.bool
546
 };
549
 };
547
 
550
 
548
 Editor.defaultProps = {
551
 Editor.defaultProps = {
564
   app: {},
567
   app: {},
565
   handleChangeFileList: () => {},
568
   handleChangeFileList: () => {},
566
   // Enter事件相关
569
   // Enter事件相关
567
-  allowEnterSubmit: false
570
+  allowEnterSubmit: false,
571
+  limitOne: false
568
 };
572
 };
569
 
573
 
570
 export default Comment(Editor);
574
 export default Comment(Editor);

+ 1
- 0
src/index.js View File

43
             });
43
             });
44
           }}
44
           }}
45
           allowEnterSubmit
45
           allowEnterSubmit
46
+          limitOne
46
         />
47
         />
47
       </App>
48
       </App>
48
     );
49
     );