zy-react-library 1.0.29 → 1.0.30

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.
@@ -12,9 +12,10 @@ export interface downloadBlobOptions {
12
12
  options?: UseDownloadBlobOptions;
13
13
  }
14
14
 
15
- export type DeleteFileFunction = (options: downloadBlobOptions) => Promise<any>;
15
+ export type DownloadBlobFunction = (options: downloadBlobOptions) => Promise<any>;
16
16
 
17
17
  /**
18
18
  * 下载Blob流文件
19
19
  */
20
- export default function useDownloadBlob(): [boolean, DeleteFileFunction];
20
+ export default function useImportFile(returnType: "array"): [boolean, DownloadBlobFunction];
21
+ export default function useImportFile(returnType?: "object"): { loading: boolean; importFile: DownloadBlobFunction };
@@ -5,7 +5,7 @@ import { useState } from "react";
5
5
  /**
6
6
  * 下载Blob流文件
7
7
  */
8
- export default function useDownloadBlob() {
8
+ export default function useDownloadBlob(returnType = "object") {
9
9
  // loading状态
10
10
  const [loading, setLoading] = useState(false);
11
11
 
@@ -14,7 +14,7 @@ export default function useDownloadBlob() {
14
14
  setLoading(true);
15
15
 
16
16
  return new Promise((resolve, reject) => {
17
- const { name= "", type= "", params= {} } = options
17
+ const { name = "", type = "", params = {} } = options;
18
18
  const finalUrl = (process.env.app.API_HOST || window.__JJB_ENVIRONMENT__.API_HOST) + url;
19
19
  Object.entries(params).forEach(([key, value]) => {
20
20
  finalUrl.searchParams.append(key, value);
@@ -58,5 +58,7 @@ export default function useDownloadBlob() {
58
58
  });
59
59
  };
60
60
 
61
- return [loading, downloadBlob];
61
+ if (returnType === "array")
62
+ return [loading, downloadBlob];
63
+ return { loading, downloadBlob };
62
64
  }
@@ -21,4 +21,5 @@ export type ImportFileFunction = (url: string, options: UseImportFileOptions) =>
21
21
  /**
22
22
  * 导入文件
23
23
  */
24
- export default function useImportFile(): [boolean, ImportFileFunction];
24
+ export default function useImportFile(returnType: "array"): [boolean, ImportFileFunction];
25
+ export default function useImportFile(returnType?: "object"): { loading: boolean; importFile: ImportFileFunction };
@@ -1,10 +1,10 @@
1
- import {request} from "@cqsjjb/jjb-common-lib/http";
1
+ import { request } from "@cqsjjb/jjb-common-lib/http";
2
2
  import { useState } from "react";
3
3
 
4
4
  /**
5
5
  * 导入文件
6
6
  */
7
- export default function useImportFile() {
7
+ export default function useImportFile(returnType = "object") {
8
8
  // loading状态
9
9
  const [loading, setLoading] = useState(false);
10
10
 
@@ -13,7 +13,7 @@ export default function useImportFile() {
13
13
  setLoading(true);
14
14
 
15
15
  return new Promise((resolve, reject) => {
16
- const { files = [], params = {} } = options
16
+ const { files = [], params = {} } = options;
17
17
  const formData = new FormData();
18
18
 
19
19
  // 将文件添加到formData中
@@ -40,5 +40,7 @@ export default function useImportFile() {
40
40
  });
41
41
  };
42
42
 
43
- return [loading, importFile];
43
+ if (returnType === "array")
44
+ return [loading, importFile];
45
+ return { loading, importFile };
44
46
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zy-react-library",
3
3
  "private": false,
4
- "version": "1.0.29",
4
+ "version": "1.0.30",
5
5
  "type": "module",
6
6
  "description": "",
7
7
  "author": "LiuJiaNan",