Bladeren bron

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

Evo 4 jaren geleden
bovenliggende
commit
a888ebe920
2 gewijzigde bestanden met toevoegingen van 9 en 4 verwijderingen
  1. 8
    4
      src/components/Editor/index.js
  2. 1
    0
      src/index.js

+ 8
- 4
src/components/Editor/index.js Bestand weergeven

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

+ 1
- 0
src/index.js Bestand weergeven

@@ -43,6 +43,7 @@ class Index extends React.Component {
43 43
             });
44 44
           }}
45 45
           allowEnterSubmit
46
+          limitOne
46 47
         />
47 48
       </App>
48 49
     );