@lightsoft/js-sdk 1.0.0 → 1.0.2

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/dist/index.d.ts CHANGED
@@ -1,8 +1,87 @@
1
+ import { Ref } from 'vue';
2
+
3
+ type RequestOptions = {
4
+ data?: Document | XMLHttpRequestBodyInit | null;
5
+ headers?: {
6
+ [key: string]: string;
7
+ };
8
+ async?: boolean;
9
+ };
10
+ type RequestType = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD' | 'TRACE' | 'CONNECT';
11
+
12
+ declare class Request {
13
+ private readonly xhr;
14
+ private beforeRequestOptions;
15
+ private beforeResponseCallback;
16
+ constructor();
17
+ create(): XMLHttpRequest;
18
+ useState(state: 'SUCCESS' | 'FAIL' | 'PENDING'): boolean;
19
+ send(type: RequestType, url: string, options?: RequestOptions): Promise<unknown>;
20
+ transformResponse(response: XMLHttpRequest): {
21
+ data: any;
22
+ code: number;
23
+ message: string;
24
+ };
25
+ transformQuery(url: string, query: any): string;
26
+ beforeSend(callback: () => RequestOptions): void;
27
+ beforeResponse(callback: (...args: any) => void): void;
28
+ abort(): void;
29
+ get(url: string, query?: any, headers?: RequestOptions['headers']): Promise<unknown>;
30
+ post(url: string, data?: any, headers?: RequestOptions['headers']): Promise<unknown>;
31
+ put(url: string, data?: any, headers?: RequestOptions['headers']): Promise<unknown>;
32
+ delete(url: string, data?: any, headers?: RequestOptions['headers']): Promise<unknown>;
33
+ patch(url: string, data?: any, headers?: RequestOptions['headers']): Promise<unknown>;
34
+ options(url: string, data?: any, headers?: RequestOptions['headers']): Promise<unknown>;
35
+ head(url: string, data?: any, headers?: RequestOptions['headers']): Promise<unknown>;
36
+ trace(url: string, data?: any, headers?: RequestOptions['headers']): Promise<unknown>;
37
+ connect(url: string, data?: any, headers?: RequestOptions['headers']): Promise<unknown>;
38
+ }
39
+ declare class RequestChain {
40
+ private fieldList;
41
+ private responses;
42
+ constructor(...args: Record<string, any>[]);
43
+ getParams(type: 'query' | 'body', data: any, fields: any): string | Record<string, any>;
44
+ setParams(...args: Record<string, any>[]): void;
45
+ chain(list: any[]): any;
46
+ }
47
+
48
+ interface CountDown {
49
+ countdownText: Ref<string>;
50
+ disabled: Ref<boolean>;
51
+ send: () => void;
52
+ }
53
+ /**
54
+ *
55
+ * @param {number} num 倒计时时间
56
+ * @param {string} text 按钮文本
57
+ * @returns { object } countdownText 倒计时文本 isDisabled 是否禁用 send 发送验证码方法
58
+ * @description 发送验证码倒计时
59
+ */
60
+ declare function useCountDown(num: number, text?: string): CountDown;
61
+
1
62
  declare enum RecordType {
2
63
  AUDIO = "audio",
3
64
  VIDEO = "video",
4
65
  SCREEN = "screen"
5
66
  }
67
+ declare enum LOGIN_TYPE {
68
+ CODE = "CODE",
69
+ ACCOUNT = "ACCOUNT"
70
+ }
71
+ declare enum LENGTH_LIMIT {
72
+ MIN_11 = 11,
73
+ MAX_11 = 11,
74
+ MIN_18 = 18,
75
+ MAX_18 = 18,
76
+ MIN_15 = 15,
77
+ MAX_15 = 15
78
+ }
79
+ declare enum HAS_FEILD {
80
+ LABEL = "label",
81
+ VALUE = "value",
82
+ CHILDREN = "children",
83
+ LEAF = "leaf"
84
+ }
6
85
 
7
86
  interface Tag {
8
87
  type: 'node' | 'content';
@@ -15,6 +94,187 @@ interface Tag {
15
94
  $class?: string;
16
95
  $disabledFor?: boolean;
17
96
  }
97
+ type typeIsNull = string | number | boolean | null | undefined;
98
+ interface ISectoralTable {
99
+ address: string;
100
+ appletQr: string;
101
+ hasChildren?: boolean;
102
+ cldOrgDepts?: ISectoralTable[];
103
+ deptAlias: string;
104
+ initialPinyin: string;
105
+ deptCode: string;
106
+ deptName: string;
107
+ email: string;
108
+ leader: string;
109
+ mark: string;
110
+ officialQr: string;
111
+ orgCode: string;
112
+ parentCode: string;
113
+ phone: string;
114
+ pk: string;
115
+ sort: number;
116
+ status: number;
117
+ }
118
+
119
+ /**
120
+ * 对象数组转为字符串
121
+ * @param {object} obj 目标对象
122
+ * @param {string | string[]} keys 键名
123
+ * @param {string} splitter 分隔符
124
+ */
125
+ declare function objectArrayToString(obj: {
126
+ [key: string]: any;
127
+ }, keys: string | string[], splitter?: string): {
128
+ [key: string]: any;
129
+ };
130
+ /**
131
+ * 防抖
132
+ * @param {Function} fn 回调函数
133
+ * @param {number} delay 延迟时间
134
+ */
135
+ declare function debounce(fn: <T>(v: T) => void, delay: number): (value: string) => void;
136
+ /**
137
+ *
138
+ * 判断是否移动端
139
+ * @return {boolean}
140
+ */
141
+ declare function isMobileDevice(): boolean;
142
+ /**
143
+ * 节流
144
+ * @param {Function} fn 回调函数
145
+ * @param {number} delay 延迟时间
146
+ */
147
+ declare function throttle(fn: <T>(v: T) => void, delay: number): (value: string) => void;
148
+ /**
149
+ * 深度合并对象
150
+ * @param target 目标对象
151
+ * @param source 源对象
152
+ */
153
+ declare function deepMerge<T>(target: T, source: T): T;
154
+ /**
155
+ * input类型验证
156
+ */
157
+ declare class InputLegalityValidate {
158
+ private _phoneReg;
159
+ private _mailReg;
160
+ private _idCardReg;
161
+ /**
162
+ * 验证手机号
163
+ * @param phone 手机号
164
+ */
165
+ phone(phone: string): boolean;
166
+ /**
167
+ * 验证邮箱
168
+ * @param email 手机号
169
+ */
170
+ email(email: string): boolean;
171
+ /**
172
+ * 验证身份证
173
+ * @param idCard 身份证号
174
+ */
175
+ idCard(idCard: string): boolean;
176
+ }
177
+ /**
178
+ * input长度验证
179
+ */
180
+ declare class InputLengthValidate {
181
+ private validators;
182
+ private checkLength;
183
+ private maxLength;
184
+ constructor();
185
+ limitLength(value: string, limit: number): string;
186
+ }
187
+ /**
188
+ * 检查值是否为空
189
+ * @param value 要检查的值
190
+ * @return {boolean} 如果值为空返回 true,否则返回 false
191
+ */
192
+ declare function isNull(value: typeIsNull): boolean;
193
+ /**
194
+ * 对数型结构进行数据处理和映射关系
195
+ */
196
+ type Mapping = Record<string, string>;
197
+ declare class dataHandler {
198
+ private fields;
199
+ private node;
200
+ private mapping;
201
+ constructor(fields: typeof HAS_FEILD, node: any, mapping: Mapping);
202
+ private processNode;
203
+ private processAllNodes;
204
+ getProcessedData(): any;
205
+ }
206
+ /**
207
+ * @param data 树形数据
208
+ * @param targetDeptCode 子节点DeptCode
209
+ * @returns 查找叶子节点并返回路径
210
+ */
211
+ declare function findTreeDataNode(data: ISectoralTable[], targetDeptCode: string): string | null;
212
+ /**
213
+ * @param dept 树形数据
214
+ * @param queryString 子节点DeptCode
215
+ * @param results 查找结果集
216
+ */
217
+ declare function findTreeDataNodeName(dept: ISectoralTable, queryString: string, results: ISectoralTable[]): void;
218
+
219
+ declare class Mask {
220
+ private task;
221
+ private selectors;
222
+ private opacity;
223
+ private elementIndex;
224
+ constructor(selectors: string[], opacity?: number);
225
+ start(): void;
226
+ process(handle: (resolve: any, index: number, element: Element) => void): this;
227
+ open(element?: Element): void;
228
+ close(): void;
229
+ }
230
+
231
+ type TourPlaceholder = {
232
+ title: string;
233
+ text: string;
234
+ next: string;
235
+ };
236
+ declare class Tour {
237
+ private selectors;
238
+ private elementIndex;
239
+ private tourTargetElement;
240
+ private tourElement;
241
+ private tourElementContentTemplate;
242
+ private placeholder;
243
+ private config;
244
+ constructor(selectors: string[]);
245
+ setPlaceholder(placeholder: TourPlaceholder): void;
246
+ setContentTemplate(template: string): void;
247
+ setConfig(config: Partial<typeof this.config>): void;
248
+ start(): void;
249
+ layout(element: HTMLElement): void;
250
+ close(): void;
251
+ }
252
+
253
+ type WebSocketState = 'CONNECTING' | 'OPEN' | 'CLOSING' | 'CLOSED';
254
+ interface WebSocketConfig {
255
+ timeout?: number;
256
+ reconnect: boolean;
257
+ reconnectTime?: number;
258
+ maxReconnectNumber?: number;
259
+ }
260
+ declare function createWebSocket(url: string, config: WebSocketConfig | null, onOpen?: Function | null): WebSocket;
261
+ declare function useSendMessage(ws: WebSocket, data: any): void;
262
+ declare function useWebSocketMessage(ws: WebSocket, callback: Function): void;
263
+ declare function useWebSocketClose(ws: WebSocket, code?: number, message?: string): void;
264
+ declare function getState(ws: WebSocket, type: WebSocketState): boolean;
265
+
266
+ /**
267
+ * 匹配中文字母数字
268
+ */
269
+ declare const ZN_LETTER_NUMBER: RegExp;
270
+ /**
271
+ * 匹配 IP
272
+ */
273
+ declare const IP: RegExp;
274
+ /**
275
+ * 匹配手机号
276
+ */
277
+ declare const PHONE: RegExp;
18
278
 
19
- export { RecordType };
20
- export type { Tag };
279
+ export { HAS_FEILD, IP, InputLegalityValidate, InputLengthValidate, LENGTH_LIMIT, LOGIN_TYPE, Mask, PHONE, RecordType, Request, RequestChain, Tour, ZN_LETTER_NUMBER, createWebSocket, dataHandler, debounce, deepMerge, findTreeDataNode, findTreeDataNodeName, getState, isMobileDevice, isNull, objectArrayToString, throttle, useCountDown, useSendMessage, useWebSocketClose, useWebSocketMessage };
280
+ export type { ISectoralTable, Tag, typeIsNull };