zy-react-library 1.0.58 → 1.0.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,6 +19,8 @@ export interface UploadProps extends Omit<AntUploadProps, "fileList"> {
19
19
  uploadButtonText?: string;
20
20
  /** 要上传的文件类型,默认为 image */
21
21
  fileType?: "image" | "video" | "document";
22
+ /** 获取上传过服务器删除的附件 */
23
+ onGetRemoveFile?: (file: UploadFile) => void;
22
24
  }
23
25
 
24
26
  /**
@@ -28,7 +30,3 @@ export interface UploadProps extends Omit<AntUploadProps, "fileList"> {
28
30
  declare const Upload: FC<UploadProps>;
29
31
 
30
32
  export default Upload;
31
-
32
- // 视频:数量默认1个,且只支持mp4格式,单个文件大小默认100M
33
- // 文件:数量默认4个,且只支持pdf、doc、docx格式
34
- // 图片:数量默认4个,且只支持jpg、jpeg、png格式
@@ -10,6 +10,9 @@ const Upload = (props) => {
10
10
  value = [],
11
11
  onChange,
12
12
  onPreview,
13
+ onRemove,
14
+ onGetRemoveFile,
15
+ beforeUpload,
13
16
  maxCount: externalMaxCount,
14
17
  listType: externalListType,
15
18
  accept: externalAccept,
@@ -127,7 +130,9 @@ const Upload = (props) => {
127
130
  return `${tips.join(",")}。`;
128
131
  };
129
132
 
130
- const handleBeforeUpload = () => {
133
+ const handleBeforeUpload = (file, fileList) => {
134
+ if (beforeUpload)
135
+ return beforeUpload(file, fileList)
131
136
  return false;
132
137
  };
133
138
 
@@ -186,6 +191,13 @@ const Upload = (props) => {
186
191
  }
187
192
  };
188
193
 
194
+ // 删除文件
195
+ const handleRemove = (file) => {
196
+ if (!file.originFileObj)
197
+ onGetRemoveFile?.(file);
198
+ return onRemove?.(file);
199
+ }
200
+
189
201
  // 预览文件
190
202
  const handlePreview = (file) => {
191
203
  if (isImageType) {
@@ -227,6 +239,7 @@ const Upload = (props) => {
227
239
  accept={accept}
228
240
  onChange={handleChange}
229
241
  onPreview={handlePreview}
242
+ onRemove={handleRemove}
230
243
  beforeUpload={handleBeforeUpload}
231
244
  {...restProps}
232
245
  >
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zy-react-library",
3
3
  "private": false,
4
- "version": "1.0.58",
4
+ "version": "1.0.60",
5
5
  "type": "module",
6
6
  "description": "",
7
7
  "author": "LiuJiaNan",