@wzyjs/utils 0.0.7 → 0.0.11

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.
Files changed (55) hide show
  1. package/dist/cjs/common/index.d.ts +5 -0
  2. package/dist/cjs/{tools → common/tools}/index.d.ts +0 -0
  3. package/dist/cjs/{tools → common/tools}/object.d.ts +0 -0
  4. package/dist/cjs/{tools → common/tools}/object.js +0 -0
  5. package/dist/cjs/common/tools/other.d.ts +14 -0
  6. package/dist/cjs/common/tools/other.js +50 -0
  7. package/dist/cjs/{tools → common/tools}/string.d.ts +0 -0
  8. package/dist/cjs/{tools → common/tools}/string.js +0 -0
  9. package/dist/cjs/{types → common/types}/index.d.ts +1 -1
  10. package/dist/cjs/fe/index.d.ts +15 -0
  11. package/dist/cjs/index.d.ts +2 -22
  12. package/dist/cjs/index_c.d.ts +2 -0
  13. package/dist/cjs/index_c.js +105 -0
  14. package/dist/cjs/rd/database/Collection.d.ts +22 -0
  15. package/dist/cjs/rd/database/Collection.js +202 -0
  16. package/dist/cjs/rd/database/Database.d.ts +10 -0
  17. package/dist/cjs/rd/database/Database.js +25 -0
  18. package/dist/cjs/rd/database/index.d.ts +2 -0
  19. package/dist/cjs/rd/database/types.d.ts +151 -0
  20. package/dist/cjs/rd/database/types.js +25 -0
  21. package/dist/cjs/rd/database/utils.d.ts +3 -0
  22. package/dist/cjs/rd/database/utils.js +30 -0
  23. package/dist/cjs/rd/index.d.ts +1 -0
  24. package/dist/esm/common/index.d.ts +5 -0
  25. package/dist/esm/{tools → common/tools}/index.d.ts +0 -0
  26. package/dist/esm/{tools → common/tools}/object.d.ts +0 -0
  27. package/dist/esm/{tools → common/tools}/object.js +0 -0
  28. package/dist/esm/common/tools/other.d.ts +14 -0
  29. package/dist/esm/common/tools/other.js +46 -0
  30. package/dist/esm/{tools → common/tools}/string.d.ts +0 -0
  31. package/dist/esm/{tools → common/tools}/string.js +0 -0
  32. package/dist/esm/{types → common/types}/index.d.ts +1 -1
  33. package/dist/esm/fe/index.d.ts +15 -0
  34. package/dist/esm/fe/index.js +14 -0
  35. package/dist/esm/index.d.ts +2 -22
  36. package/dist/esm/index.js +8 -18
  37. package/dist/esm/index_c.d.ts +2 -0
  38. package/dist/esm/rd/database/Collection.d.ts +22 -0
  39. package/dist/esm/rd/database/Database.d.ts +10 -0
  40. package/dist/esm/rd/database/index.d.ts +2 -0
  41. package/dist/esm/rd/database/types.d.ts +151 -0
  42. package/dist/esm/rd/database/utils.d.ts +3 -0
  43. package/dist/esm/rd/index.d.ts +1 -0
  44. package/package.json +6 -9
  45. package/dist/cjs/hooks/index.d.ts +0 -1
  46. package/dist/cjs/hooks/useRequestPro.d.ts +0 -11
  47. package/dist/cjs/hooks/useRequestPro.js +0 -37
  48. package/dist/cjs/index.js +0 -78
  49. package/dist/cjs/tools/other.d.ts +0 -6
  50. package/dist/cjs/tools/other.js +0 -24
  51. package/dist/esm/hooks/index.d.ts +0 -1
  52. package/dist/esm/hooks/useRequestPro.d.ts +0 -11
  53. package/dist/esm/hooks/useRequestPro.js +0 -35
  54. package/dist/esm/tools/other.d.ts +0 -6
  55. package/dist/esm/tools/other.js +0 -22
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ // 查询数据库的条件 - 比较的特殊条件
4
+ exports.Command = void 0;
5
+ (function (Command) {
6
+ Command["Eq"] = "eq";
7
+ Command["Neq"] = "neq";
8
+ Command["Lt"] = "lt";
9
+ Command["Lte"] = "lte";
10
+ Command["Gt"] = "gt";
11
+ Command["Gte"] = "gte";
12
+ Command["In"] = "in";
13
+ Command["Nin"] = "nin";
14
+ Command["Gtlt"] = "gtlt";
15
+ })(exports.Command || (exports.Command = {}));
16
+ // 查询的方法
17
+ exports.Method = void 0;
18
+ (function (Method) {
19
+ Method["Add"] = "add";
20
+ Method["Find"] = "find";
21
+ Method["FindList"] = "findList";
22
+ Method["Delete"] = "delete";
23
+ Method["Update"] = "update";
24
+ Method["Count"] = "count";
25
+ })(exports.Method || (exports.Method = {}));
@@ -0,0 +1,3 @@
1
+ import { Conditions } from './types';
2
+ export declare const appendTime: <D>(data: D, type: 'create' | 'update') => D;
3
+ export declare const defaultConditions: Conditions;
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ // 给记录添加时间
4
+ const appendTime = (data, type) => {
5
+ if (!data) {
6
+ return {};
7
+ }
8
+ return {
9
+ ...data,
10
+ [type + 'At']: Date.now(),
11
+ };
12
+ };
13
+ // 默认条件
14
+ const defaultConditions = {
15
+ order: {
16
+ field: 'createAt',
17
+ type: 'desc',
18
+ },
19
+ options: {
20
+ timeout: 10000,
21
+ multiple: true,
22
+ },
23
+ page: {
24
+ current: 1,
25
+ size: 10,
26
+ },
27
+ };
28
+
29
+ exports.appendTime = appendTime;
30
+ exports.defaultConditions = defaultConditions;
@@ -0,0 +1 @@
1
+ export * from './database';
@@ -0,0 +1,5 @@
1
+ import { cloneDeep, debounce, isBoolean, isEqual, isFunction, isNumber, isObject, isString, merge, omit, pick, uniq, uniqBy, uniqWith, isEmpty, isError } from 'lodash';
2
+ export { cloneDeep, debounce, isBoolean, isEqual, isFunction, isNumber, isObject, isString, merge, omit, pick, uniq, uniqBy, uniqWith, isEmpty, isError, };
3
+ export * as consola from 'consola';
4
+ export * from './tools';
5
+ export * from './types';
File without changes
File without changes
File without changes
@@ -0,0 +1,14 @@
1
+ import { KeyValue, OrderParams, Pagination, SortParams } from '../types';
2
+ export declare const handleParams: (params?: Pagination & KeyValue, sort?: SortParams) => {
3
+ page: Pagination;
4
+ where: KeyValue<string, string | number | boolean | RegExp>;
5
+ order?: OrderParams;
6
+ };
7
+ export declare const handleRes2List: <D>(reqPromise: any) => Promise<{
8
+ label: string;
9
+ value: string;
10
+ }[]>;
11
+ export declare const executePromise: (promise: Promise<any>) => Promise<{
12
+ result: any;
13
+ time: number;
14
+ }>;
@@ -0,0 +1,46 @@
1
+ // 处理 ProComponents 中 ProTable 参数中的 page 和 where 和 sort
2
+ const handleParams = (params, sort) => {
3
+ if (!params) {
4
+ return {
5
+ page: {},
6
+ where: {},
7
+ };
8
+ }
9
+ const { current, pageSize, ...other } = params;
10
+ return {
11
+ page: {
12
+ current: current || 1,
13
+ pageSize: pageSize || 10,
14
+ },
15
+ where: Object.entries(other).reduce((acc, [key, value]) => {
16
+ if (key && value) {
17
+ acc[key] = typeof value === 'string' ? new RegExp(value) : value;
18
+ }
19
+ return acc;
20
+ }, {}),
21
+ order: sort && {
22
+ field: Object.keys(sort)[0],
23
+ type: Object.values(sort)[0] === 'ascend' ? 'asc' : 'desc',
24
+ },
25
+ };
26
+ };
27
+ // 将 list 的数据处理为 { label: string, value: string }[]
28
+ const handleRes2List = async (reqPromise) => {
29
+ const { data } = await reqPromise();
30
+ return (data?.list || []).map((item) => ({
31
+ label: item.name,
32
+ value: item.key,
33
+ }));
34
+ };
35
+ // 计算执行 promise 花费的时间
36
+ const executePromise = async (promise) => {
37
+ const start = Date.now();
38
+ const result = await promise;
39
+ const time = Date.now() - start;
40
+ return {
41
+ result,
42
+ time,
43
+ };
44
+ };
45
+
46
+ export { executePromise, handleParams, handleRes2List };
File without changes
File without changes
@@ -3,7 +3,7 @@ export interface RequestRes<D = any> {
3
3
  message?: string;
4
4
  data?: D;
5
5
  }
6
- export type KeyValue<D extends object | string = string, V = string | number | boolean> = Record<D extends string ? string : keyof D, V>;
6
+ export type KeyValue<D extends object | string = string, V = any> = Partial<Record<D extends string ? string : keyof D, V>>;
7
7
  export interface Pagination {
8
8
  current?: number;
9
9
  pageSize?: number;
@@ -0,0 +1,15 @@
1
+ import md5 from 'md5';
2
+ import dayjs from 'dayjs';
3
+ import classnames from 'classnames';
4
+ import copy from 'copy-to-clipboard';
5
+ export { copy, classnames, dayjs, md5 };
6
+ export declare const localforage: {
7
+ config: {
8
+ (options: LocalForageOptions): boolean;
9
+ (options: string): any;
10
+ (): LocalForageOptions;
11
+ };
12
+ setItem: <T>(key: string, value: T, callback?: ((err: any, value: T) => void) | undefined) => Promise<T>;
13
+ getItem: <T_1>(key: string, callback?: ((err: any, value: T_1 | null) => void) | undefined) => Promise<T_1 | null>;
14
+ removeItem: (key: string, callback?: ((err: any) => void) | undefined) => Promise<void>;
15
+ };
@@ -0,0 +1,14 @@
1
+ export { default as md5 } from 'md5';
2
+ export { default as dayjs } from 'dayjs';
3
+ export { default as classnames } from 'classnames';
4
+ export { default as copy } from 'copy-to-clipboard';
5
+ import { config, setItem, getItem, removeItem } from 'localforage';
6
+
7
+ const localforage = {
8
+ config,
9
+ setItem,
10
+ getItem,
11
+ removeItem,
12
+ };
13
+
14
+ export { localforage };
@@ -1,22 +1,2 @@
1
- import dayjs from 'dayjs';
2
- import copy from 'copy-to-clipboard';
3
- import classnames from 'classnames';
4
- import consola from 'consola';
5
- import md5 from 'md5';
6
- export { copy, consola, classnames, dayjs, md5 };
7
- export * from 'ahooks';
8
- import { omit, pick, cloneDeep, isEqual, merge, isObject, isBoolean, isString, isNumber } from 'lodash';
9
- export { omit, pick, cloneDeep, isEqual, merge, isObject, isBoolean, isString, isNumber };
10
- export declare const localforage: {
11
- config: {
12
- (options: LocalForageOptions): boolean;
13
- (options: string): any;
14
- (): LocalForageOptions;
15
- };
16
- setItem: <T>(key: string, value: T, callback?: ((err: any, value: T) => void) | undefined) => Promise<T>;
17
- getItem: <T_1>(key: string, callback?: ((err: any, value: T_1 | null) => void) | undefined) => Promise<T_1 | null>;
18
- removeItem: (key: string, callback?: ((err: any) => void) | undefined) => Promise<void>;
19
- };
20
- export * from './tools';
21
- export * from './hooks';
22
- export * from './types';
1
+ export * from './common';
2
+ export * from './fe';
package/dist/esm/index.js CHANGED
@@ -1,21 +1,11 @@
1
- export { default as dayjs } from 'dayjs';
1
+ export { cloneDeep, debounce, isBoolean, isEmpty, isEqual, isError, isFunction, isNumber, isObject, isString, merge, omit, pick, uniq, uniqBy, uniqWith } from 'lodash';
2
+ import * as consola from 'consola';
3
+ export { consola };
4
+ export { getChineseByStr, getStrLength, jsonParse, replaceAll, replaceByRules } from './common/tools/string.js';
5
+ export { checkAttr } from './common/tools/object.js';
6
+ export { executePromise, handleParams, handleRes2List } from './common/tools/other.js';
7
+ export { localforage } from './fe/index.js';
2
8
  export { default as copy } from 'copy-to-clipboard';
3
9
  export { default as classnames } from 'classnames';
4
- export { default as consola } from 'consola';
10
+ export { default as dayjs } from 'dayjs';
5
11
  export { default as md5 } from 'md5';
6
- export * from 'ahooks';
7
- export { cloneDeep, isBoolean, isEqual, isNumber, isObject, isString, merge, omit, pick } from 'lodash';
8
- import { config, setItem, getItem, removeItem } from 'localforage';
9
- export { getChineseByStr, getStrLength, jsonParse, replaceAll, replaceByRules } from './tools/string.js';
10
- export { checkAttr } from './tools/object.js';
11
- export { handleParams } from './tools/other.js';
12
- export { useRequestPro } from './hooks/useRequestPro.js';
13
-
14
- const localforage = {
15
- config,
16
- setItem,
17
- getItem,
18
- removeItem,
19
- };
20
-
21
- export { localforage };
@@ -0,0 +1,2 @@
1
+ export * from './common';
2
+ export * from './rd';
@@ -0,0 +1,22 @@
1
+ import { Database, IKeyValue } from '@cloudbase/node-sdk';
2
+ import { Add, Conditions, Count, Delete, Find, FindList, IdConditions, MethodParams, Update, WhereConditions } from './types';
3
+ export declare class Collection<D extends IKeyValue> {
4
+ private readonly db;
5
+ private readonly collection;
6
+ constructor(db: Database.Db, name: string);
7
+ private joinConditions;
8
+ private request;
9
+ private handleRes;
10
+ private handleData;
11
+ handleConditions(params: MethodParams<D>): MethodParams<D>;
12
+ private exec;
13
+ add(data: Add.Params<D>['data']): Promise<Add.Res>;
14
+ add(data: Add.Params<D>['data'], isReturn: true, conditions?: Pick<IdConditions, 'field'>): Promise<Find.Res<D>>;
15
+ delete(conditions: Conditions): Promise<Delete.Res>;
16
+ update(conditions: Conditions, data: Update.Params<D>['data'], isSet?: true): Promise<Update.Res<D>>;
17
+ update(conditions: IdConditions, data: Update.Params<D>['data'], isSet?: true): Promise<Update.Res<D>>;
18
+ update(conditions: IdConditions, data: Update.Params<D>['data'], isReturn: true, isSet?: true): Promise<Find.Res<D>>;
19
+ find(conditions?: Conditions): Promise<Find.Res<D>>;
20
+ findList(conditions?: WhereConditions): Promise<FindList.Res<D>>;
21
+ count(conditions: Conditions): Promise<Count.Res>;
22
+ }
@@ -0,0 +1,10 @@
1
+ import tcb, { IKeyValue } from '@cloudbase/node-sdk';
2
+ import { Config } from './types';
3
+ import { Collection } from './Collection';
4
+ export declare class Database {
5
+ private readonly db;
6
+ private readonly instance;
7
+ constructor(config: Config);
8
+ collection<D extends IKeyValue>(name: string): Collection<D>;
9
+ createCollection(name: string): tcb.IBaseRes;
10
+ }
@@ -0,0 +1,2 @@
1
+ export { Database } from './Database';
2
+ export { Conditions, IdConditions, WhereConditions, Record } from './types';
@@ -0,0 +1,151 @@
1
+ import { Database, ICountRes } from '@cloudbase/node-sdk';
2
+ export interface Config {
3
+ env: string;
4
+ secretId: string;
5
+ secretKey: string;
6
+ }
7
+ export type IdConditions = {
8
+ _id: string;
9
+ field?: string[] | {
10
+ [key: string]: false;
11
+ };
12
+ options?: {
13
+ timeout: number;
14
+ multiple?: false;
15
+ };
16
+ };
17
+ export declare enum Command {
18
+ Eq = "eq",
19
+ Neq = "neq",
20
+ Lt = "lt",
21
+ Lte = "lte",
22
+ Gt = "gt",
23
+ Gte = "gte",
24
+ In = "in",
25
+ Nin = "nin",
26
+ Gtlt = "gtlt"
27
+ }
28
+ export type CommandWhere = {
29
+ type: Command.Eq;
30
+ value: any;
31
+ } | {
32
+ type: Command.Neq;
33
+ value: any;
34
+ } | {
35
+ type: Command.Gt;
36
+ value: number;
37
+ } | {
38
+ type: Command.Gte;
39
+ value: number;
40
+ } | {
41
+ type: Command.Lt;
42
+ value: number;
43
+ } | {
44
+ type: Command.Lte;
45
+ value: number;
46
+ } | {
47
+ type: Command.Gtlt;
48
+ value: number[];
49
+ } | {
50
+ type: Command.In;
51
+ value: any[];
52
+ } | {
53
+ type: Command.Nin;
54
+ value: any[];
55
+ };
56
+ export type WhereConditions = {
57
+ where?: {
58
+ [key: string]: any | CommandWhere;
59
+ };
60
+ field?: string[] | {
61
+ [key: string]: false;
62
+ };
63
+ page?: {
64
+ size?: number;
65
+ current?: number;
66
+ };
67
+ order?: {
68
+ field: string;
69
+ type?: 'asc' | 'desc';
70
+ };
71
+ options?: {
72
+ timeout?: number;
73
+ multiple?: boolean;
74
+ };
75
+ };
76
+ export type Conditions = IdConditions | WhereConditions;
77
+ export declare enum Method {
78
+ Add = "add",
79
+ Find = "find",
80
+ FindList = "findList",
81
+ Delete = "delete",
82
+ Update = "update",
83
+ Count = "count"
84
+ }
85
+ export declare namespace Add {
86
+ type Params<D> = {
87
+ method: Method.Add;
88
+ data: D;
89
+ conditions?: Pick<IdConditions, 'field'>;
90
+ isReturn?: true;
91
+ };
92
+ type Res = {
93
+ id: string;
94
+ };
95
+ }
96
+ export declare namespace Find {
97
+ type Params = {
98
+ method: Method.Find;
99
+ conditions?: Conditions;
100
+ };
101
+ type Res<D> = Record<D> | undefined;
102
+ }
103
+ export declare namespace FindList {
104
+ type Params = {
105
+ method: Method.FindList;
106
+ conditions?: WhereConditions;
107
+ };
108
+ type Res<D> = {
109
+ list?: Record<D>[];
110
+ total?: number;
111
+ };
112
+ }
113
+ export declare namespace Delete {
114
+ type Params = {
115
+ method: Method.Delete;
116
+ conditions: Conditions;
117
+ };
118
+ type Res = {
119
+ deleted: number | string;
120
+ };
121
+ }
122
+ export declare namespace Update {
123
+ type Params<D> = {
124
+ method: Method.Update;
125
+ conditions: Conditions;
126
+ data: Partial<Record<D>>;
127
+ isReturn?: true;
128
+ isSet?: true;
129
+ };
130
+ type Res<D> = {
131
+ updated?: number;
132
+ doc?: D;
133
+ };
134
+ }
135
+ export declare namespace Count {
136
+ type Params = {
137
+ method: Method.Count;
138
+ conditions?: WhereConditions;
139
+ };
140
+ type Res = {
141
+ total?: number;
142
+ };
143
+ }
144
+ export type MethodParams<D> = Add.Params<D> | Find.Params | FindList.Params | Delete.Params | Update.Params<D> | Count.Params;
145
+ export type MethodRes<D> = Add.Res | Find.Res<D> | FindList.Res<D> | Delete.Res | Update.Res<D> | Count.Res;
146
+ export type IRes = Database.IAddRes | Database.IGetRes | Database.IDeleteResult | Database.IUpdateResult | ICountRes;
147
+ export type Record<D> = D & {
148
+ _id: string;
149
+ createAt: number;
150
+ updateAt: number;
151
+ };
@@ -0,0 +1,3 @@
1
+ import { Conditions } from './types';
2
+ export declare const appendTime: <D>(data: D, type: 'create' | 'update') => D;
3
+ export declare const defaultConditions: Conditions;
@@ -0,0 +1 @@
1
+ export * from './database';
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@wzyjs/utils",
3
- "version": "0.0.7",
4
- "description": "> TODO: description",
5
- "author": "wzy <657189555@qq.com>",
3
+ "version": "0.0.11",
4
+ "description": "description",
5
+ "author": "wzy",
6
6
  "license": "ISC",
7
- "main": "dist/cjs/index.js",
7
+ "main": "dist/cjs/index_c.js",
8
8
  "module": "dist/esm/index.js",
9
9
  "typings": "dist/esm/index.d.ts",
10
10
  "scripts": {
@@ -15,8 +15,7 @@
15
15
  "dist"
16
16
  ],
17
17
  "dependencies": {
18
- "ahooks": "^3.7.2",
19
- "antd": "^5.0.1",
18
+ "@cloudbase/node-sdk": "^2.9.1",
20
19
  "classnames": "^2.3.2",
21
20
  "consola": "^2.15.3",
22
21
  "copy-to-clipboard": "^3.3.3",
@@ -24,8 +23,6 @@
24
23
  "localforage": "^1.10.0",
25
24
  "lodash": "^4.17.21",
26
25
  "md5": "^2.3.0",
27
- "react": "^18.2.0",
28
- "react-dom": "^18.2.0",
29
26
  "tslib": "^2.4.1"
30
27
  },
31
28
  "devDependencies": {
@@ -45,5 +42,5 @@
45
42
  "type": "git",
46
43
  "url": "https://gitee.com/wang-zhenyu/app.git"
47
44
  },
48
- "gitHead": "8e1d0fab516ee88720c772b14a72575bc790c9b1"
45
+ "gitHead": "00865dfbf006e37041dc48b3f8d6e4191d3bf75f"
49
46
  }
@@ -1 +0,0 @@
1
- export * from './useRequestPro';
@@ -1,11 +0,0 @@
1
- import { Options, Service, Result } from 'ahooks/lib/useRequest/src/types';
2
- import { RequestRes } from '../types';
3
- interface UserOptions<P extends any[], R> extends Options<R, P> {
4
- alertErrorMessage?: false | string;
5
- alertSuccessMessage?: true | string;
6
- }
7
- interface IResult<R extends RequestRes, P extends any[]> extends Omit<Result<R, P>, 'data'> {
8
- data?: R['data'];
9
- }
10
- export declare const useRequestPro: <P extends any[], R extends RequestRes<any>>(reqPromise: Service<R, P>, userOptions: UserOptions<P, R>) => IResult<R, P>;
11
- export {};
@@ -1,37 +0,0 @@
1
- 'use strict';
2
-
3
- var antd = require('antd');
4
- var lodash = require('lodash');
5
- var ahooks = require('ahooks');
6
-
7
- const useRequestPro = (reqPromise, userOptions) => {
8
- const { alertErrorMessage = true, alertSuccessMessage = false } = userOptions;
9
- const defaultOptions = {
10
- debounceWait: 300,
11
- throttleWait: 300,
12
- onError: (e, params) => {
13
- if (alertErrorMessage) {
14
- antd.message.error(typeof alertErrorMessage === 'string' ? alertErrorMessage : e.message || '请求失败');
15
- }
16
- userOptions?.onError?.(e, params);
17
- },
18
- onSuccess: (res, params) => {
19
- if (!res || !res.success) {
20
- defaultOptions.onError(new Error(res?.message), params);
21
- return;
22
- }
23
- if (alertSuccessMessage) {
24
- antd.message.success(typeof alertSuccessMessage === 'string' ? alertSuccessMessage : res.message || '请求成功');
25
- }
26
- userOptions?.onSuccess?.(res, params);
27
- },
28
- };
29
- // delete userOptions.onSuccess
30
- // delete userOptions.onError
31
- const options = Object.assign(defaultOptions, lodash.omit(userOptions, ['onSuccess', 'onError']));
32
- const state = ahooks.useRequest(reqPromise, options);
33
- state.data = state.data?.data;
34
- return state;
35
- };
36
-
37
- exports.useRequestPro = useRequestPro;
package/dist/cjs/index.js DELETED
@@ -1,78 +0,0 @@
1
- 'use strict';
2
-
3
- var dayjs = require('dayjs');
4
- var copyToClipboard = require('copy-to-clipboard');
5
- var classnames = require('classnames');
6
- var consola = require('consola');
7
- var md5 = require('md5');
8
- var ahooks = require('ahooks');
9
- var lodash = require('lodash');
10
- var localforage$1 = require('localforage');
11
- var string = require('./tools/string.js');
12
- var object = require('./tools/object.js');
13
- var other = require('./tools/other.js');
14
- var useRequestPro = require('./hooks/useRequestPro.js');
15
-
16
- const localforage = {
17
- config: localforage$1.config,
18
- setItem: localforage$1.setItem,
19
- getItem: localforage$1.getItem,
20
- removeItem: localforage$1.removeItem,
21
- };
22
-
23
- exports.dayjs = dayjs;
24
- exports.copy = copyToClipboard;
25
- exports.classnames = classnames;
26
- exports.consola = consola;
27
- exports.md5 = md5;
28
- Object.defineProperty(exports, 'cloneDeep', {
29
- enumerable: true,
30
- get: function () { return lodash.cloneDeep; }
31
- });
32
- Object.defineProperty(exports, 'isBoolean', {
33
- enumerable: true,
34
- get: function () { return lodash.isBoolean; }
35
- });
36
- Object.defineProperty(exports, 'isEqual', {
37
- enumerable: true,
38
- get: function () { return lodash.isEqual; }
39
- });
40
- Object.defineProperty(exports, 'isNumber', {
41
- enumerable: true,
42
- get: function () { return lodash.isNumber; }
43
- });
44
- Object.defineProperty(exports, 'isObject', {
45
- enumerable: true,
46
- get: function () { return lodash.isObject; }
47
- });
48
- Object.defineProperty(exports, 'isString', {
49
- enumerable: true,
50
- get: function () { return lodash.isString; }
51
- });
52
- Object.defineProperty(exports, 'merge', {
53
- enumerable: true,
54
- get: function () { return lodash.merge; }
55
- });
56
- Object.defineProperty(exports, 'omit', {
57
- enumerable: true,
58
- get: function () { return lodash.omit; }
59
- });
60
- Object.defineProperty(exports, 'pick', {
61
- enumerable: true,
62
- get: function () { return lodash.pick; }
63
- });
64
- exports.getChineseByStr = string.getChineseByStr;
65
- exports.getStrLength = string.getStrLength;
66
- exports.jsonParse = string.jsonParse;
67
- exports.replaceAll = string.replaceAll;
68
- exports.replaceByRules = string.replaceByRules;
69
- exports.checkAttr = object.checkAttr;
70
- exports.handleParams = other.handleParams;
71
- exports.useRequestPro = useRequestPro.useRequestPro;
72
- exports.localforage = localforage;
73
- Object.keys(ahooks).forEach(function (k) {
74
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
75
- enumerable: true,
76
- get: function () { return ahooks[k]; }
77
- });
78
- });
@@ -1,6 +0,0 @@
1
- import { KeyValue, OrderParams, Pagination, SortParams } from '../types';
2
- export declare const handleParams: (params: Pagination & KeyValue, sort?: SortParams) => {
3
- page: Pagination;
4
- where: KeyValue<string, string | number | boolean | RegExp>;
5
- order?: OrderParams;
6
- };
@@ -1,24 +0,0 @@
1
- 'use strict';
2
-
3
- // 处理 ProComponents 中 ProTable 参数中的 page 和 查询条件 和 排序
4
- const handleParams = (params, sort) => {
5
- const { current, pageSize, ...other } = params;
6
- return {
7
- page: {
8
- current: current || 1,
9
- pageSize: pageSize || 10,
10
- },
11
- where: Object.entries(other).reduce((acc, [key, value]) => {
12
- if (key && value) {
13
- acc[key] = typeof value === 'string' ? new RegExp(value) : value;
14
- }
15
- return acc;
16
- }, {}),
17
- order: sort && {
18
- field: Object.keys(sort)[0],
19
- type: Object.values(sort)[0] === 'ascend' ? 'asc' : 'desc',
20
- },
21
- };
22
- };
23
-
24
- exports.handleParams = handleParams;
@@ -1 +0,0 @@
1
- export * from './useRequestPro';
@@ -1,11 +0,0 @@
1
- import { Options, Service, Result } from 'ahooks/lib/useRequest/src/types';
2
- import { RequestRes } from '../types';
3
- interface UserOptions<P extends any[], R> extends Options<R, P> {
4
- alertErrorMessage?: false | string;
5
- alertSuccessMessage?: true | string;
6
- }
7
- interface IResult<R extends RequestRes, P extends any[]> extends Omit<Result<R, P>, 'data'> {
8
- data?: R['data'];
9
- }
10
- export declare const useRequestPro: <P extends any[], R extends RequestRes<any>>(reqPromise: Service<R, P>, userOptions: UserOptions<P, R>) => IResult<R, P>;
11
- export {};