@fe-free/core 1.3.5 → 1.4.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @fe-free/core
2
2
 
3
+ ## 1.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - feat: ahooks fix
8
+
9
+ ### Patch Changes
10
+
11
+ - @fe-free/tool@1.4.0
12
+
3
13
  ## 1.3.5
4
14
 
5
15
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/core",
3
- "version": "1.3.5",
3
+ "version": "1.4.0",
4
4
  "description": "",
5
5
  "main": "./src/index.ts",
6
6
  "author": "",
@@ -36,7 +36,7 @@
36
36
  "react-syntax-highlighter": "^15.5.0",
37
37
  "vanilla-jsoneditor": "^0.23.1",
38
38
  "zustand": "^4.5.4",
39
- "@fe-free/tool": "1.3.5"
39
+ "@fe-free/tool": "1.4.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@ant-design/pro-components": "^2.8.7",
@@ -0,0 +1,21 @@
1
+ import { useInfiniteScroll } from 'ahooks';
2
+ import type { Data, InfiniteScrollOptions, Service } from 'ahooks/lib/useInfiniteScroll/types';
3
+
4
+ function useGlobalInfiniteScroll<TData extends Data>(
5
+ service: Service<TData>,
6
+ options?: InfiniteScrollOptions<TData>,
7
+ ) {
8
+ return useInfiniteScroll(service, {
9
+ onError: (error) => {
10
+ // 全局抛出错误
11
+ setTimeout(() => {
12
+ throw error;
13
+ }, 0);
14
+ },
15
+ ...options,
16
+ // @ts-ignore
17
+ __ignore: true,
18
+ });
19
+ }
20
+
21
+ export { useGlobalInfiniteScroll };
@@ -0,0 +1,26 @@
1
+ import { useRequest } from 'ahooks';
2
+ import type { Options, Plugin, Service } from 'ahooks/es/useRequest/src/types';
3
+
4
+ function useGlobalRequest<TData, TParams extends any[]>(
5
+ service: Service<TData, TParams>,
6
+ options?: Options<TData, TParams>,
7
+ plugins?: Plugin<TData, TParams>[],
8
+ ) {
9
+ return useRequest(
10
+ service,
11
+ {
12
+ onError: (error) => {
13
+ // 全局抛出错误
14
+ setTimeout(() => {
15
+ throw error;
16
+ }, 0);
17
+ },
18
+ ...options,
19
+ // @ts-ignore
20
+ __ignore: true,
21
+ },
22
+ plugins,
23
+ );
24
+ }
25
+
26
+ export { useGlobalRequest };
package/src/index.ts CHANGED
@@ -1,3 +1,6 @@
1
+ export { useGlobalInfiniteScroll } from './ahooks/use_global_infinite_scroll';
2
+ export { useGlobalRequest } from './ahooks/use_global_request';
3
+
1
4
  export { LoadingButton } from './button';
2
5
 
3
6
  export { CRUD, CRUDDetail, CRUDOfSimple, OperateDelete, useDelete } from './crud';