@wzyjs/utils 0.0.30 → 0.1.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.
Files changed (176) hide show
  1. package/dist/{browser/cjs/utils/src → cjs}/browser/element.d.ts +9 -9
  2. package/dist/cjs/browser/element.js +59 -0
  3. package/dist/{node/cjs/utils/src → cjs}/browser/index.d.ts +18 -18
  4. package/dist/cjs/browser/index.js +64 -0
  5. package/dist/{browser/cjs/utils/src → cjs}/browser/other.d.ts +1 -1
  6. package/dist/cjs/browser/other.js +35 -0
  7. package/dist/{browser/esm/utils/src → cjs}/browser/style.d.ts +10 -10
  8. package/dist/cjs/browser/style.js +81 -0
  9. package/dist/{browser/cjs/utils/src → cjs}/browser.d.ts +2 -2
  10. package/dist/cjs/browser.js +25 -0
  11. package/dist/{browser/esm/utils/src → cjs}/common/classs.d.ts +5 -5
  12. package/dist/cjs/common/classs.js +36 -0
  13. package/dist/{browser/cjs/utils/src → cjs}/common/dayjs.d.ts +4 -4
  14. package/dist/cjs/common/dayjs.js +57 -0
  15. package/dist/{node/cjs/utils/src → cjs}/common/index.d.ts +11 -11
  16. package/dist/cjs/common/index.js +99 -0
  17. package/dist/{browser/cjs/utils/src → cjs}/common/number.d.ts +3 -3
  18. package/dist/cjs/common/number.js +55 -0
  19. package/dist/{browser/esm/utils/src → cjs}/common/object.d.ts +10 -10
  20. package/dist/cjs/common/object.js +65 -0
  21. package/dist/{node/esm/utils/src → cjs}/common/other.d.ts +26 -26
  22. package/dist/cjs/common/other.js +129 -0
  23. package/dist/{browser/cjs/utils/src → cjs}/common/string.d.ts +16 -16
  24. package/dist/cjs/common/string.js +157 -0
  25. package/dist/{node/cjs/utils/src → cjs}/node/database/Collection.d.ts +22 -22
  26. package/dist/cjs/node/database/Collection.js +219 -0
  27. package/dist/{node/cjs/utils/src → cjs}/node/database/Database.d.ts +10 -10
  28. package/dist/cjs/node/database/Database.js +47 -0
  29. package/dist/{browser/esm/utils/src → cjs}/node/database/index.d.ts +2 -2
  30. package/dist/cjs/node/database/index.js +38 -0
  31. package/dist/{node/esm/utils/src → cjs}/node/database/types.d.ts +151 -151
  32. package/dist/cjs/node/database/types.js +51 -0
  33. package/dist/{browser/cjs/utils/src → cjs}/node/database/utils.d.ts +3 -3
  34. package/dist/cjs/node/database/utils.js +53 -0
  35. package/dist/{browser/cjs/utils/src → cjs}/node/index.d.ts +3 -3
  36. package/dist/cjs/node/index.js +27 -0
  37. package/dist/{node/cjs/utils/src → cjs}/node/jsonFile/index.d.ts +6 -6
  38. package/dist/cjs/node/jsonFile/index.js +51 -0
  39. package/dist/{browser/cjs/utils/src → cjs}/node/mail/index.d.ts +1 -1
  40. package/dist/cjs/node/mail/index.js +67 -0
  41. package/dist/{node/cjs/utils/src → cjs}/node.d.ts +2 -2
  42. package/dist/cjs/node.js +25 -0
  43. package/dist/{node/cjs/utils/src → esm}/browser/element.d.ts +9 -9
  44. package/dist/esm/browser/element.js +43 -0
  45. package/dist/{node/esm/utils/src → esm}/browser/index.d.ts +18 -18
  46. package/dist/esm/browser/index.js +15 -0
  47. package/dist/{node/cjs/utils/src → esm}/browser/other.d.ts +1 -1
  48. package/dist/esm/browser/other.js +28 -0
  49. package/dist/{browser/cjs/utils/src → esm}/browser/style.d.ts +10 -10
  50. package/dist/esm/browser/style.js +55 -0
  51. package/dist/{node/cjs/utils/src → esm}/browser.d.ts +2 -2
  52. package/dist/esm/browser.js +2 -0
  53. package/dist/{browser/cjs/utils/src → esm}/common/classs.d.ts +5 -5
  54. package/dist/esm/common/classs.js +33 -0
  55. package/dist/{browser/esm/utils/src → esm}/common/dayjs.d.ts +4 -4
  56. package/dist/{browser/esm → esm}/common/dayjs.js +10 -10
  57. package/dist/{node/esm/utils/src → esm}/common/index.d.ts +11 -11
  58. package/dist/{browser/cjs/utils/src/common/index.d.ts → esm/common/index.js} +12 -11
  59. package/dist/{browser/esm/utils/src → esm}/common/number.d.ts +3 -3
  60. package/dist/esm/common/number.js +31 -0
  61. package/dist/{node/cjs/utils/src → esm}/common/object.d.ts +10 -10
  62. package/dist/esm/common/object.js +84 -0
  63. package/dist/{browser/esm/utils/src → esm}/common/other.d.ts +26 -26
  64. package/dist/esm/common/other.js +173 -0
  65. package/dist/{browser/esm/utils/src → esm}/common/string.d.ts +16 -16
  66. package/dist/esm/common/string.js +140 -0
  67. package/dist/{browser/cjs/utils/src → esm}/node/database/Collection.d.ts +22 -22
  68. package/dist/esm/node/database/Collection.js +356 -0
  69. package/dist/{browser/cjs/utils/src → esm}/node/database/Database.d.ts +10 -10
  70. package/dist/esm/node/database/Database.js +36 -0
  71. package/dist/{node/cjs/utils/src → esm}/node/database/index.d.ts +2 -2
  72. package/dist/{browser/cjs/utils/src/node/database/index.d.ts → esm/node/database/index.js} +2 -2
  73. package/dist/{node/cjs/utils/src → esm}/node/database/types.d.ts +151 -151
  74. package/dist/esm/node/database/types.js +55 -0
  75. package/dist/{browser/esm/utils/src → esm}/node/database/utils.d.ts +3 -3
  76. package/dist/esm/node/database/utils.js +29 -0
  77. package/dist/{browser/esm/utils/src → esm}/node/index.d.ts +3 -3
  78. package/dist/esm/node/index.js +3 -0
  79. package/dist/{browser/cjs/utils/src → esm}/node/jsonFile/index.d.ts +6 -6
  80. package/dist/esm/node/jsonFile/index.js +43 -0
  81. package/dist/{browser/esm/utils/src → esm}/node/mail/index.d.ts +1 -1
  82. package/dist/esm/node/mail/index.js +48 -0
  83. package/dist/{browser/cjs/utils/src → esm}/node.d.ts +2 -2
  84. package/dist/esm/node.js +2 -0
  85. package/package.json +10 -23
  86. package/dist/browser/cjs/browser/element.js +0 -40
  87. package/dist/browser/cjs/browser/index.js +0 -20
  88. package/dist/browser/cjs/browser/other.js +0 -12
  89. package/dist/browser/cjs/browser/style.js +0 -49
  90. package/dist/browser/cjs/browser.js +0 -171
  91. package/dist/browser/cjs/common/classs.js +0 -14
  92. package/dist/browser/cjs/common/dayjs.js +0 -27
  93. package/dist/browser/cjs/common/number.js +0 -34
  94. package/dist/browser/cjs/common/object.js +0 -43
  95. package/dist/browser/cjs/common/other.js +0 -112
  96. package/dist/browser/cjs/common/string.js +0 -137
  97. package/dist/browser/cjs/types/index.d.ts +0 -27
  98. package/dist/browser/cjs/utils/src/browser/index.d.ts +0 -18
  99. package/dist/browser/cjs/utils/src/common/object.d.ts +0 -10
  100. package/dist/browser/cjs/utils/src/common/other.d.ts +0 -26
  101. package/dist/browser/cjs/utils/src/node/database/types.d.ts +0 -151
  102. package/dist/browser/esm/browser/element.js +0 -36
  103. package/dist/browser/esm/browser/index.js +0 -14
  104. package/dist/browser/esm/browser/other.js +0 -10
  105. package/dist/browser/esm/browser/style.js +0 -45
  106. package/dist/browser/esm/browser.js +0 -19
  107. package/dist/browser/esm/common/classs.js +0 -12
  108. package/dist/browser/esm/common/number.js +0 -30
  109. package/dist/browser/esm/common/object.js +0 -39
  110. package/dist/browser/esm/common/other.js +0 -106
  111. package/dist/browser/esm/common/string.js +0 -120
  112. package/dist/browser/esm/types/index.d.ts +0 -27
  113. package/dist/browser/esm/utils/src/browser/element.d.ts +0 -9
  114. package/dist/browser/esm/utils/src/browser/index.d.ts +0 -18
  115. package/dist/browser/esm/utils/src/browser/other.d.ts +0 -1
  116. package/dist/browser/esm/utils/src/browser.d.ts +0 -2
  117. package/dist/browser/esm/utils/src/common/index.d.ts +0 -11
  118. package/dist/browser/esm/utils/src/node/database/Collection.d.ts +0 -22
  119. package/dist/browser/esm/utils/src/node/database/Database.d.ts +0 -10
  120. package/dist/browser/esm/utils/src/node/database/types.d.ts +0 -151
  121. package/dist/browser/esm/utils/src/node/jsonFile/index.d.ts +0 -6
  122. package/dist/browser/esm/utils/src/node.d.ts +0 -2
  123. package/dist/node/cjs/common/classs.js +0 -14
  124. package/dist/node/cjs/common/dayjs.js +0 -27
  125. package/dist/node/cjs/common/number.js +0 -34
  126. package/dist/node/cjs/common/object.js +0 -43
  127. package/dist/node/cjs/common/other.js +0 -112
  128. package/dist/node/cjs/common/string.js +0 -137
  129. package/dist/node/cjs/node/database/Collection.js +0 -202
  130. package/dist/node/cjs/node/database/Database.js +0 -25
  131. package/dist/node/cjs/node/database/types.js +0 -25
  132. package/dist/node/cjs/node/database/utils.js +0 -30
  133. package/dist/node/cjs/node/jsonFile/index.js +0 -29
  134. package/dist/node/cjs/node/mail/index.js +0 -31
  135. package/dist/node/cjs/node.js +0 -157
  136. package/dist/node/cjs/types/index.d.ts +0 -27
  137. package/dist/node/cjs/utils/src/browser/style.d.ts +0 -10
  138. package/dist/node/cjs/utils/src/common/classs.d.ts +0 -5
  139. package/dist/node/cjs/utils/src/common/dayjs.d.ts +0 -4
  140. package/dist/node/cjs/utils/src/common/number.d.ts +0 -3
  141. package/dist/node/cjs/utils/src/common/other.d.ts +0 -26
  142. package/dist/node/cjs/utils/src/common/string.d.ts +0 -16
  143. package/dist/node/cjs/utils/src/node/database/utils.d.ts +0 -3
  144. package/dist/node/cjs/utils/src/node/index.d.ts +0 -3
  145. package/dist/node/cjs/utils/src/node/mail/index.d.ts +0 -1
  146. package/dist/node/esm/common/classs.js +0 -12
  147. package/dist/node/esm/common/dayjs.js +0 -18
  148. package/dist/node/esm/common/number.js +0 -30
  149. package/dist/node/esm/common/object.js +0 -39
  150. package/dist/node/esm/common/other.js +0 -106
  151. package/dist/node/esm/common/string.js +0 -120
  152. package/dist/node/esm/node/database/Collection.js +0 -200
  153. package/dist/node/esm/node/database/Database.js +0 -23
  154. package/dist/node/esm/node/database/types.js +0 -25
  155. package/dist/node/esm/node/database/utils.js +0 -27
  156. package/dist/node/esm/node/jsonFile/index.js +0 -27
  157. package/dist/node/esm/node/mail/index.js +0 -29
  158. package/dist/node/esm/node.js +0 -14
  159. package/dist/node/esm/types/index.d.ts +0 -27
  160. package/dist/node/esm/utils/src/browser/element.d.ts +0 -9
  161. package/dist/node/esm/utils/src/browser/other.d.ts +0 -1
  162. package/dist/node/esm/utils/src/browser/style.d.ts +0 -10
  163. package/dist/node/esm/utils/src/browser.d.ts +0 -2
  164. package/dist/node/esm/utils/src/common/classs.d.ts +0 -5
  165. package/dist/node/esm/utils/src/common/dayjs.d.ts +0 -4
  166. package/dist/node/esm/utils/src/common/number.d.ts +0 -3
  167. package/dist/node/esm/utils/src/common/object.d.ts +0 -10
  168. package/dist/node/esm/utils/src/common/string.d.ts +0 -16
  169. package/dist/node/esm/utils/src/node/database/Collection.d.ts +0 -22
  170. package/dist/node/esm/utils/src/node/database/Database.d.ts +0 -10
  171. package/dist/node/esm/utils/src/node/database/index.d.ts +0 -2
  172. package/dist/node/esm/utils/src/node/database/utils.d.ts +0 -3
  173. package/dist/node/esm/utils/src/node/index.d.ts +0 -3
  174. package/dist/node/esm/utils/src/node/jsonFile/index.d.ts +0 -6
  175. package/dist/node/esm/utils/src/node/mail/index.d.ts +0 -1
  176. package/dist/node/esm/utils/src/node.d.ts +0 -2
@@ -1,151 +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
- };
1
+ import { Database, ICountRes } from '@cloudbase/node-sdk';
2
+ export interface Config {
3
+ env: string;
4
+ secretId: string;
5
+ secretKey: string;
6
+ }
7
+ export declare 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 declare 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 declare 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 declare 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 declare type MethodParams<D> = Add.Params<D> | Find.Params | FindList.Params | Delete.Params | Update.Params<D> | Count.Params;
145
+ export declare type MethodRes<D> = Add.Res | Find.Res<D> | FindList.Res<D> | Delete.Res | Update.Res<D> | Count.Res;
146
+ export declare type IRes = Database.IAddRes | Database.IGetRes | Database.IDeleteResult | Database.IUpdateResult | ICountRes;
147
+ export declare type Record<D> = D & {
148
+ _id: string;
149
+ createAt: number;
150
+ updateAt: number;
151
+ };
@@ -0,0 +1,55 @@
1
+ // 连接数据库的配置
2
+
3
+ // 查询数据库的条件
4
+
5
+ // 查询数据库的条件 - 比较的特殊条件
6
+ export var Command = /*#__PURE__*/function (Command) {
7
+ Command["Eq"] = "eq";
8
+ Command["Neq"] = "neq";
9
+ Command["Lt"] = "lt";
10
+ Command["Lte"] = "lte";
11
+ Command["Gt"] = "gt";
12
+ Command["Gte"] = "gte";
13
+ Command["In"] = "in";
14
+ Command["Nin"] = "nin";
15
+ Command["Gtlt"] = "gtlt";
16
+ return Command;
17
+ }({});
18
+ // 查询的方法
19
+ export var Method = /*#__PURE__*/function (Method) {
20
+ Method["Add"] = "add";
21
+ Method["Find"] = "find";
22
+ Method["FindList"] = "findList";
23
+ Method["Delete"] = "delete";
24
+ Method["Update"] = "update";
25
+ Method["Count"] = "count";
26
+ return Method;
27
+ }({});
28
+
29
+ // 增加
30
+ export var Add;
31
+
32
+ // 查询
33
+ (function (_Add) {})(Add || (Add = {}));
34
+ export var Find;
35
+
36
+ // 查询列表
37
+ (function (_Find) {})(Find || (Find = {}));
38
+ export var FindList;
39
+
40
+ // 删除
41
+ (function (_FindList) {})(FindList || (FindList = {}));
42
+ export var Delete;
43
+
44
+ // 更新
45
+ (function (_Delete) {})(Delete || (Delete = {}));
46
+ export var Update;
47
+
48
+ // 数量
49
+ (function (_Update) {})(Update || (Update = {}));
50
+ export var Count;
51
+
52
+ // 方法的参数
53
+ (function (_Count) {})(Count || (Count = {})); // 方法的返回
54
+ // 查询的返回
55
+ // 数据在表里的类型
@@ -1,3 +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;
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,29 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ // 给记录添加时间
8
+ export var appendTime = function appendTime(data, type) {
9
+ if (!data) {
10
+ return {};
11
+ }
12
+ return _objectSpread(_objectSpread({}, data), {}, _defineProperty({}, type + 'At', Date.now()));
13
+ };
14
+
15
+ // 默认条件
16
+ export var defaultConditions = {
17
+ order: {
18
+ field: 'createAt',
19
+ type: 'desc'
20
+ },
21
+ options: {
22
+ timeout: 10000,
23
+ multiple: true
24
+ },
25
+ page: {
26
+ current: 1,
27
+ size: 10
28
+ }
29
+ };
@@ -1,3 +1,3 @@
1
- export * from './database';
2
- export * from './jsonFile';
3
- export * from './mail';
1
+ export * from './database';
2
+ export * from './jsonFile';
3
+ export * from './mail';
@@ -0,0 +1,3 @@
1
+ export * from "./database";
2
+ export * from "./jsonFile";
3
+ export * from "./mail";
@@ -1,6 +1,6 @@
1
- export declare class JsonFile {
2
- filePath: string;
3
- constructor(filePath: string);
4
- get(key: string): Promise<unknown>;
5
- set(key: string, value: any): void;
6
- }
1
+ export declare class JsonFile {
2
+ filePath: string;
3
+ constructor(filePath: string);
4
+ get(key: string): Promise<unknown>;
5
+ set(key: string, value: any): void;
6
+ }
@@ -0,0 +1,43 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
4
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
+ var fs = require('fs');
9
+ var path = require('path');
10
+
11
+ // 实现一个文件系统读写数据库
12
+ export var JsonFile = /*#__PURE__*/function () {
13
+ function JsonFile(filePath) {
14
+ _classCallCheck(this, JsonFile);
15
+ _defineProperty(this, "filePath", void 0);
16
+ this.filePath = path.resolve(__dirname, filePath);
17
+ }
18
+ _createClass(JsonFile, [{
19
+ key: "get",
20
+ value: function get(key) {
21
+ var _this = this;
22
+ return new Promise(function (resolve) {
23
+ fs.readFile(_this.filePath, function (err, data) {
24
+ var json = data ? JSON.parse(data) : {};
25
+ resolve(json[key]);
26
+ });
27
+ });
28
+ }
29
+ }, {
30
+ key: "set",
31
+ value: function set(key, value) {
32
+ var _this2 = this;
33
+ fs.readFile(this.filePath, {
34
+ encoding: 'utf-8'
35
+ }, function (err, data) {
36
+ var json = data ? JSON.parse(data || '{}') : {};
37
+ json[key] = value;
38
+ fs.writeFile(_this2.filePath, JSON.stringify(json), function () {});
39
+ });
40
+ }
41
+ }]);
42
+ return JsonFile;
43
+ }();
@@ -1 +1 @@
1
- export declare const sendMail: (toEmail: string, title: string, content?: string) => Promise<string>;
1
+ export declare const sendMail: (toEmail: string, title: string, content?: string) => Promise<string>;
@@ -0,0 +1,48 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ import nodemailer from 'nodemailer';
6
+ var fromEmail = '15835196981@163.com';
7
+ var fromPass = 'KPTVCFBMRXJVTCGW';
8
+ var transporter = nodemailer.createTransport({
9
+ host: 'smtp.163.com',
10
+ port: 465,
11
+ secure: true,
12
+ auth: {
13
+ user: fromEmail,
14
+ pass: fromPass
15
+ }
16
+ });
17
+ export var sendMail = /*#__PURE__*/function () {
18
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(toEmail, title, content) {
19
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
20
+ while (1) switch (_context.prev = _context.next) {
21
+ case 0:
22
+ _context.prev = 0;
23
+ _context.next = 3;
24
+ return transporter.sendMail({
25
+ from: fromEmail,
26
+ // 发件人邮箱
27
+ to: toEmail,
28
+ // 收件人邮箱
29
+ subject: title,
30
+ // 邮件主题
31
+ text: content // 邮件正文
32
+ });
33
+ case 3:
34
+ return _context.abrupt("return", title + ' 邮件通知成功');
35
+ case 6:
36
+ _context.prev = 6;
37
+ _context.t0 = _context["catch"](0);
38
+ return _context.abrupt("return", title + '邮件通知失败' + JSON.stringify(_context.t0));
39
+ case 9:
40
+ case "end":
41
+ return _context.stop();
42
+ }
43
+ }, _callee, null, [[0, 6]]);
44
+ }));
45
+ return function sendMail(_x, _x2, _x3) {
46
+ return _ref.apply(this, arguments);
47
+ };
48
+ }();
@@ -1,2 +1,2 @@
1
- export * from './common';
2
- export * from './node/index';
1
+ export * from './common';
2
+ export * from './node/index';
@@ -0,0 +1,2 @@
1
+ export * from "./common";
2
+ export * from "./node/index";
package/package.json CHANGED
@@ -1,32 +1,22 @@
1
1
  {
2
2
  "name": "@wzyjs/utils",
3
- "version": "0.0.30",
3
+ "version": "0.1.0",
4
4
  "description": "description",
5
5
  "author": "wzy",
6
6
  "license": "ISC",
7
7
  "exports": {
8
8
  ".": {
9
- "import": "./dist/browser/esm/browser.js",
10
- "require": "./dist/browser/cjs/browser.js"
9
+ "import": "./dist/esm/browser.js",
10
+ "require": "./dist/cjs/browser.js"
11
11
  },
12
12
  "./node": {
13
- "import": "./dist/node/esm/node.js",
14
- "require": "./dist/node/cjs/node.js"
15
- }
16
- },
17
- "typesVersions": {
18
- "*": {
19
- "*": [
20
- "./dist/browser/esm/utils/src/browser.d.ts"
21
- ],
22
- "node": [
23
- "./dist/node/esm/utils/src/node.d.ts"
24
- ]
13
+ "import": "./dist/esm/node.js",
14
+ "require": "./dist/cjs/node.js"
25
15
  }
26
16
  },
27
17
  "scripts": {
28
- "dev": "rollup -c -w --bundleConfigAsCjs",
29
- "build": "rollup -c --bundleConfigAsCjs"
18
+ "dev": "father dev",
19
+ "build": "father build"
30
20
  },
31
21
  "files": [
32
22
  "dist"
@@ -46,16 +36,13 @@
46
36
  "zod": "^3.21.4"
47
37
  },
48
38
  "devDependencies": {
49
- "@rollup/plugin-commonjs": "^23.0.3",
50
- "@rollup/plugin-node-resolve": "^15.0.1",
51
39
  "@types/animejs": "^3.1.6",
52
40
  "@types/lodash": "^4.14.189",
53
41
  "@types/md5": "^2.3.2",
54
42
  "@types/node": "^18.11.11",
55
43
  "@types/nodemailer": "^6.4.7",
56
- "@wzyjs/types": "^0.0.30",
57
- "rollup": "^3.6.0",
58
- "rollup-plugin-typescript2": "^0.34.1",
44
+ "@wzyjs/types": "^0.1.0",
45
+ "father": "^4.2.3",
59
46
  "typescript": "^4.9.3"
60
47
  },
61
48
  "publishConfig": {
@@ -65,5 +52,5 @@
65
52
  "type": "git",
66
53
  "url": "https://gitee.com/wang-zhenyu/app.git"
67
54
  },
68
- "gitHead": "c8e042a5bb184b3842ec4f04d2edd671a0ac2802"
55
+ "gitHead": "3efe774801f46de9c70693ace99d01eb7fb06da1"
69
56
  }
@@ -1,40 +0,0 @@
1
- 'use strict';
2
-
3
- // 滚动到让指定元素显示出来的位置
4
- const scrollIntoView = (el, option) => {
5
- if (!el) {
6
- return;
7
- }
8
- el.scrollIntoView({ behavior: 'smooth', block: 'start', ...option });
9
- };
10
- // 获取指定元素 已经元素原始的样式
11
- const getElement = (el) => {
12
- const element = typeof el === 'string' ? document.querySelector(el) : el;
13
- if (!element) {
14
- return {
15
- element: null,
16
- originalStyle: {},
17
- };
18
- }
19
- // 获取元素原始的样式
20
- return {
21
- element,
22
- originalStyle: window.getComputedStyle(element),
23
- };
24
- };
25
- // 判断元素是否在可见范围内
26
- const isElementInViewport = (el) => {
27
- const { element } = getElement(el);
28
- if (!element) {
29
- return;
30
- }
31
- const rect = element.getBoundingClientRect();
32
- return (rect.top >= 0 &&
33
- rect.left >= 0 &&
34
- rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
35
- rect.right <= (window.innerWidth || document.documentElement.clientWidth));
36
- };
37
-
38
- exports.getElement = getElement;
39
- exports.isElementInViewport = isElementInViewport;
40
- exports.scrollIntoView = scrollIntoView;