@partex/one-core 2.0.105 → 2.0.106

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.
@@ -1,2 +1,3 @@
1
1
  export { useDebounceFn } from './useDebounceFn';
2
2
  export { useThrottleFn } from './useThrottleFn';
3
+ export { useQuery } from './useQuery';
@@ -1,10 +1,26 @@
1
- import type { Fn } from './utils';
1
+ import { DebouncedFunc } from 'lodash';
2
+ /// <reference types="lodash" />
3
+ import type { Fn } from '../interface';
2
4
  /**
3
5
  * 处理防抖函数
4
6
  * @param fn
5
7
  * @param delay
6
8
  * @returns
7
9
  */
8
- export declare const useDebounceFn: (fn: Fn, delay?: number) => {
9
- run: () => void;
10
+ export declare function useDebounceFn(fn: Fn, wait?: number): {
11
+ /**
12
+ * Invode and pass parameters to fn.
13
+ * `(...args: any[]) => any`
14
+ */
15
+ run: DebouncedFunc<Fn<any, any>>;
16
+ /**
17
+ * Cancel the invocation of currently debounced function.
18
+ * `() => void`
19
+ */
20
+ cancel: () => void;
21
+ /**
22
+ * Immediately invoke currently debounced function.
23
+ * `() => void`
24
+ */
25
+ flush: () => any;
10
26
  };
@@ -0,0 +1,25 @@
1
+ import type { Fn } from '../interface';
2
+ import type { Ref } from 'vue';
3
+ type Status = 'loading' | 'idle' | 'error' | 'success';
4
+ interface IQueryResult {
5
+ status: Ref<Status>;
6
+ loading: Ref<boolean>;
7
+ error: Ref<any>;
8
+ data: any;
9
+ stopPollingInterval: () => void;
10
+ cancel: () => void;
11
+ refetch: () => void;
12
+ }
13
+ interface IQueryOptions {
14
+ cache?: boolean;
15
+ manual?: boolean;
16
+ pollingInterval?: number;
17
+ retry?: {
18
+ retryCount?: number;
19
+ retryInterval?: number;
20
+ };
21
+ formatResult?: Fn;
22
+ initialData?: Fn;
23
+ }
24
+ export declare function useQuery(queryKey: string, fetch: Promise<any> | Promise<any>[], options?: IQueryOptions): IQueryResult;
25
+ export {};
@@ -1,10 +1,15 @@
1
- import type { Fn } from './utils';
1
+ import { DebouncedFunc } from 'lodash';
2
+ import { ComputedRef } from 'vue';
3
+ /// <reference types="lodash" />
4
+ import type { Fn } from '../interface';
2
5
  /**
3
6
  * 处理节流函数
4
7
  * @param fn
5
8
  * @param delay
6
9
  * @returns
7
10
  */
8
- export declare const useThrottleFn: (fn: Fn, delay?: number) => {
9
- run: Fn;
11
+ export declare function useThrottleFn(fn: Fn, wait?: number): {
12
+ run: ComputedRef<DebouncedFunc<(...args: Parameters<Fn>) => ReturnType<Fn>>>;
13
+ cancel: () => void;
14
+ flush: () => any;
10
15
  };
@@ -114,8 +114,8 @@ declare const _default: DefineComponent<{
114
114
  cols: number;
115
115
  defaultValue: Record<string, any>;
116
116
  value: Record<string, any>;
117
- autoSubmit: boolean;
118
117
  cache: boolean;
118
+ autoSubmit: boolean;
119
119
  resetButton: boolean;
120
120
  }, {}>;
121
121
  export default _default;
@@ -266,8 +266,8 @@ declare const _default: DefineComponent<{
266
266
  defaultCheckedRowKeys: (string | number)[];
267
267
  flexHeight: boolean;
268
268
  filters: ObjectKey;
269
- autoSubmit: boolean;
270
269
  cache: boolean;
270
+ autoSubmit: boolean;
271
271
  resetButton: boolean;
272
272
  fetch: Fn<any, any>;
273
273
  actionsWidth: string | number;
@@ -1,4 +1,4 @@
1
1
  import type { AxiosInstance } from 'axios';
2
2
  declare const fetch: AxiosInstance;
3
- export default fetch;
4
3
  export declare const fnCancelFetch: () => void;
4
+ export default fetch;