zy-react-library 1.0.48 → 1.0.49
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.
- package/hooks/useUploadFile/index.js +12 -4
- package/package.json +1 -1
|
@@ -38,16 +38,24 @@ function useUploadFile(returnType = "object") {
|
|
|
38
38
|
throw new Error(`未找到 type ${params.type} 对应的 path `);
|
|
39
39
|
|
|
40
40
|
// 当single为false时,foreignKey是必需的
|
|
41
|
-
if (!single
|
|
42
|
-
|
|
41
|
+
if (!single) {
|
|
42
|
+
if (!params.hasOwnProperty('foreignKey'))
|
|
43
|
+
throw new Error("请传入 options.params.foreignKey");
|
|
44
|
+
// 如果 foreignKey 是 undefined,设置默认值为空字符串
|
|
45
|
+
if (params.foreignKey === undefined || params.foreignKey === null)
|
|
46
|
+
params.foreignKey = "";
|
|
47
|
+
}
|
|
43
48
|
|
|
44
49
|
// 如果没有文件则直接返回
|
|
45
|
-
if (files.length === 0)
|
|
50
|
+
if (files.length === 0) {
|
|
51
|
+
setLoading(false);
|
|
46
52
|
resolve(
|
|
47
53
|
single
|
|
48
54
|
? { filePath: '' }
|
|
49
|
-
: { id:
|
|
55
|
+
: { id: params.foreignKey },
|
|
50
56
|
);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
51
59
|
|
|
52
60
|
const formData = new FormData();
|
|
53
61
|
|