@partex/one-core 2.0.106 → 2.0.108

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,7 +1,7 @@
1
1
  import type { ObjectKey, PageModel, PageRecords, Query, Fn } from './interface';
2
2
  export declare const getDefaultDate: (year?: number, month?: number, date?: number) => number;
3
- export declare function fnSetStorage(key: string, value: string | ObjectKey | boolean, expired?: number | string): void;
4
- export declare function fnGetStorage(key: string, defaultValue: any): any;
3
+ export declare function fnSetStorage<T>(key: string, value: T, expired?: number | string): void;
4
+ export declare function fnGetStorage<T = any>(key: string, defaultValue: any): T;
5
5
  export declare const fnDelStorage: (key: string) => void;
6
6
  export declare const fnScrollTop: (value?: number) => void;
7
7
  export declare const fnDeleteLoad: () => void;
@@ -1,3 +1,4 @@
1
1
  export { useDebounceFn } from './useDebounceFn';
2
2
  export { useThrottleFn } from './useThrottleFn';
3
+ export { useLocalStorage } from './useLocalStorage';
3
4
  export { useQuery } from './useQuery';
@@ -2,7 +2,7 @@ import { DebouncedFunc } from 'lodash';
2
2
  /// <reference types="lodash" />
3
3
  import type { Fn } from '../interface';
4
4
  /**
5
- * 处理防抖函数
5
+ * 防抖函数
6
6
  * @param fn
7
7
  * @param delay
8
8
  * @returns
@@ -0,0 +1,29 @@
1
+ import type { Ref, UnwrapRef } from 'vue';
2
+ interface ILocalStorageOptions<T> {
3
+ /**
4
+ * 默认数据
5
+ */
6
+ defaultValue?: T;
7
+ /**
8
+ * 过期时间
9
+ */
10
+ expired: number | string;
11
+ }
12
+ type ILocalStorageAction<T> = [
13
+ /**
14
+ * 数据
15
+ */
16
+ Ref<UnwrapRef<T> | undefined>,
17
+ /**
18
+ * 设置数据
19
+ */
20
+ (value?: T) => void
21
+ ];
22
+ /**
23
+ * 获取LocalStorage数据
24
+ * @param key 緩存Key {string}
25
+ * @param options 配置 {ILocalStorageOptions}
26
+ * @returns ILocalStorageAction {ILocalStorageAction}
27
+ */
28
+ export declare function useLocalStorage<T>(key: string, options?: ILocalStorageOptions<T>): ILocalStorageAction<T>;
29
+ export {};
@@ -1,25 +1,77 @@
1
1
  import type { Fn } from '../interface';
2
2
  import type { Ref } from 'vue';
3
3
  type Status = 'loading' | 'idle' | 'error' | 'success';
4
- interface IQueryResult {
4
+ interface IQueryResult<T> {
5
+ /**
6
+ * 请求状态
7
+ */
5
8
  status: Ref<Status>;
9
+ /**
10
+ * 加载状态
11
+ */
6
12
  loading: Ref<boolean>;
7
- error: Ref<any>;
8
- data: any;
13
+ /**
14
+ * 错误信息
15
+ */
16
+ error: Ref<unknown>;
17
+ /**
18
+ * 返回值
19
+ */
20
+ data: Readonly<Ref<T | undefined>>;
21
+ /**
22
+ * 停止轮询
23
+ */
9
24
  stopPollingInterval: () => void;
25
+ /**
26
+ * 取消请求
27
+ */
10
28
  cancel: () => void;
29
+ /**
30
+ * 重新请求
31
+ */
11
32
  refetch: () => void;
12
33
  }
13
34
  interface IQueryOptions {
35
+ /**
36
+ * 开启缓存
37
+ */
14
38
  cache?: boolean;
39
+ /**
40
+ * 手动触发
41
+ */
15
42
  manual?: boolean;
43
+ /**
44
+ * 轮询
45
+ */
16
46
  pollingInterval?: number;
47
+ /**
48
+ * 错误重试
49
+ */
17
50
  retry?: {
51
+ /**
52
+ * 重试次数
53
+ */
18
54
  retryCount?: number;
55
+ /**
56
+ * 重试间隔
57
+ */
19
58
  retryInterval?: number;
20
59
  };
60
+ /**
61
+ * 返回数据格式化
62
+ */
21
63
  formatResult?: Fn;
64
+ /**
65
+ * 初始化数据
66
+ */
22
67
  initialData?: Fn;
23
68
  }
24
- export declare function useQuery(queryKey: string, fetch: Promise<any> | Promise<any>[], options?: IQueryOptions): IQueryResult;
69
+ /**
70
+ * 获取查询数据
71
+ * @param queryKey 緩存Key {string}
72
+ * @param fetch 請求Promise {Fn<any, Promise<any>> | Fn<any, Promise<any>>[]}
73
+ * @param options 配置 {IQueryOptions}
74
+ * @returns IQueryResult {IQueryResult}
75
+ */
76
+ export declare function useQuery<T>(queryKey: string, fetch: Fn<any, Promise<any>> | Fn<any, Promise<any>>[], options?: IQueryOptions): IQueryResult<T>;
25
77
  export {};
@@ -1,15 +1,14 @@
1
1
  import { DebouncedFunc } from 'lodash';
2
- import { ComputedRef } from 'vue';
3
2
  /// <reference types="lodash" />
4
3
  import type { Fn } from '../interface';
5
4
  /**
6
- * 处理节流函数
5
+ * 节流函数
7
6
  * @param fn
8
7
  * @param delay
9
8
  * @returns
10
9
  */
11
10
  export declare function useThrottleFn(fn: Fn, wait?: number): {
12
- run: ComputedRef<DebouncedFunc<(...args: Parameters<Fn>) => ReturnType<Fn>>>;
11
+ run: DebouncedFunc<(...args: Parameters<Fn>) => ReturnType<Fn>>;
13
12
  cancel: () => void;
14
13
  flush: () => any;
15
14
  };
@@ -1,15 +1,12 @@
1
- type ObjectKey<T = any> = {
2
- [x in string | number]: T;
3
- };
1
+ import type { ObjectKey } from '../interface';
4
2
  export default class LzLocalStorage {
5
3
  namespace: string;
6
4
  mapKey: string;
7
5
  map: ObjectKey;
8
6
  constructor(namespace?: string);
9
- set(key: string, value: string | ObjectKey | boolean, expires?: number): void;
7
+ set<T>(key: string, value: T, expires?: number): void;
10
8
  getReallyKey(key: string): string;
11
- get<T>(key: string, defaultValue: T): T;
9
+ get<T>(key: string, defaultValue: T): any;
12
10
  delete(key: string): void;
13
11
  deleteAll(): void;
14
12
  }
15
- export {};