@vuetkit/core 0.0.3 → 0.0.5

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/README.md CHANGED
@@ -9,3 +9,7 @@ Collection of business development hooks for Vue3 projects.
9
9
  ### Network
10
10
 
11
11
  - [useRequest](/core/src/network/useRequest/)
12
+
13
+ ### File
14
+
15
+ - [useAsyncDownloadFile](/core/src/file/useAsyncDownloadFile/)
package/dist/index.d.ts CHANGED
@@ -21,4 +21,12 @@ interface RequestReturn<T> {
21
21
  type RequestService = (params?: any) => Promise<unknown>;
22
22
  declare function useRequest<T>(service: RequestService, options?: RequestOptions<T>): RequestReturn<T>;
23
23
  //#endregion
24
- export { RequestOptions, RequestReturn, RequestService, useRequest };
24
+ //#region src/file/useAsyncDownloadFile/index.d.ts
25
+ declare function useAsyncDownloadFile(downloadService: RequestService, fileName: string): {
26
+ downloadColumns: import("vue").Ref<number[], number[]>;
27
+ changeDownloadColumns: (ids: number[]) => void;
28
+ executeDownload: (params?: any) => void;
29
+ loading: import("vue").Ref<boolean, boolean>;
30
+ };
31
+ //#endregion
32
+ export { RequestOptions, RequestReturn, RequestService, useAsyncDownloadFile, useRequest };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { realObj } from "@vuetkit/shared";
1
+ import { downloadFile, realObj } from "@vuetkit/shared";
2
2
  import { onMounted, onUnmounted, ref, shallowRef, toValue } from "vue";
3
3
  //#region src/network/useRequest/index.ts
4
4
  function useRequest(service, options) {
@@ -91,4 +91,24 @@ function useRequest(service, options) {
91
91
  };
92
92
  }
93
93
  //#endregion
94
- export { useRequest };
94
+ //#region src/file/useAsyncDownloadFile/index.ts
95
+ function useAsyncDownloadFile(downloadService, fileName) {
96
+ const downloadColumns = ref([]);
97
+ const changeDownloadColumns = (ids) => {
98
+ downloadColumns.value = ids;
99
+ };
100
+ const { loading, execute: executeDownload } = useRequest(downloadService, {
101
+ manual: true,
102
+ onSuccess: (data) => {
103
+ downloadFile(data, fileName);
104
+ }
105
+ });
106
+ return {
107
+ downloadColumns,
108
+ changeDownloadColumns,
109
+ executeDownload,
110
+ loading
111
+ };
112
+ }
113
+ //#endregion
114
+ export { useAsyncDownloadFile, useRequest };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vuetkit/core",
3
3
  "type": "module",
4
- "version": "0.0.3",
4
+ "version": "0.0.5",
5
5
  "description": "Collection of business development hooks for Vue3 projects",
6
6
  "author": "Kalu5",
7
7
  "license": "MIT",
@@ -19,6 +19,9 @@
19
19
  "peerDependencies": {
20
20
  "vue": "^3.5.35"
21
21
  },
22
+ "dependencies": {
23
+ "@vuetkit/shared": "0.0.5"
24
+ },
22
25
  "scripts": {
23
26
  "build": "tsdown --config-loader tsx"
24
27
  }