zy-react-library 1.0.47 → 1.0.48

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.
@@ -24,12 +24,36 @@ function useDeleteFile(returnType = "object") {
24
24
  throw new Error("请传入有效的 files");
25
25
 
26
26
  // 如果没有文件则直接返回
27
- if (files.length === 0)
27
+ if (files.length === 0) {
28
+ setLoading(false);
28
29
  resolve();
30
+ return;
31
+ }
32
+
33
+ // 单文件并且没有文件路径则直接返回
34
+ if (single) {
35
+ const firstFile = files[0];
36
+ if (!firstFile.filePath) {
37
+ setLoading(false);
38
+ resolve();
39
+ return;
40
+ }
41
+ }
42
+ // 多文件并且没有文件id则直接返回
43
+ else {
44
+ const validFiles = files.filter(f => f.id);
45
+ if (validFiles.length === 0) {
46
+ setLoading(false);
47
+ resolve();
48
+ return;
49
+ }
50
+ }
29
51
 
30
52
  // 发送请求
31
53
  request(
32
- single ? `/basic-info/imgFiles/delete?filePath=${files[0].filePath}` : `/basic-info/imgFiles/ids?ids=${files.map(f => f.id)}`,
54
+ single
55
+ ? `/basic-info/imgFiles/delete?filePath=${files[0].filePath}`
56
+ : `/basic-info/imgFiles/ids?ids=${files.filter(f => f.id).map(f => f.id)}`,
33
57
  "delete",
34
58
  )
35
59
  .then((res) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zy-react-library",
3
3
  "private": false,
4
- "version": "1.0.47",
4
+ "version": "1.0.48",
5
5
  "type": "module",
6
6
  "description": "",
7
7
  "author": "LiuJiaNan",