@lingxiteam/ebe-utils 0.0.33 → 0.0.35
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/es/index.d.ts +5 -1
- package/es/index.js +107 -62
- package/lib/h5public/src/components/factory/src/Icon/IconED/index.less +43 -0
- package/lib/h5public/src/components/factory/src/Icon/IconED/index.tsx +290 -0
- package/lib/public/src/services/api/engine.ts +0 -2
- package/lib/public/src/utils/Security/clientCapabilities.ts +8 -0
- package/lib/public/src/utils/Security/config.ts +56 -49
- package/lib/public/src/utils/Security/const.ts +38 -127
- package/lib/public/src/utils/Security/debug/data.ts +86 -0
- package/lib/public/src/utils/Security/debug/index.ts +21 -0
- package/lib/public/src/utils/Security/encipher/sign.ts +25 -56
- package/lib/public/src/utils/Security/html.ts +52 -0
- package/lib/public/src/utils/Security/httpEncryption.ts +42 -23
- package/lib/public/src/utils/Security/index.ts +15 -7
- package/lib/public/src/utils/Security/requester/fetch.ts +87 -52
- package/lib/public/src/utils/Security/requester/wx.ts +60 -11
- package/lib/public/src/utils/Security/requester/xhr.ts +194 -40
- package/lib/public/src/utils/Security/types.ts +8 -90
- package/lib/public/src/utils/Security/urlEncryption.ts +108 -0
- package/lib/public/src/utils/Security/utils/atob.ts +34 -0
- package/lib/public/src/utils/Security/utils/caseInsensitive.ts +25 -0
- package/lib/public/src/utils/Security/utils/check.ts +27 -3
- package/lib/public/src/utils/Security/utils/cookie.ts +101 -53
- package/lib/public/src/utils/Security/utils/encrypted.ts +190 -43
- package/lib/public/src/utils/Security/utils/random.ts +21 -0
- package/lib/public/src/utils/Security/utils/storge.ts +22 -0
- package/lib/public/src/utils/Security/utils/url.ts +30 -5
- package/lib/public/src/utils/getSceneCode.ts +51 -0
- package/lib/public/src/utils/useTool.ts +2 -172
- package/lib/public/yarn.lock +11441 -0
- package/package.json +3 -3
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/closeIcon.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/fileName.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/img.png +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* eslint-disable no-restricted-properties */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 生成随机整数
|
|
5
|
+
* @param numDigits 随机数位数
|
|
6
|
+
* @returns 随机数
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
function generateRandomNumber(numDigits: number) {
|
|
10
|
+
// 确保输入的位数为正整数
|
|
11
|
+
const _numDigits = Math.floor(Math.abs(numDigits));
|
|
12
|
+
|
|
13
|
+
// 生成指定位数的最小值和最大值
|
|
14
|
+
const min = Math.pow(10, _numDigits - 1);
|
|
15
|
+
const max = Math.pow(10, _numDigits) - 1;
|
|
16
|
+
|
|
17
|
+
// 生成随机数并返回
|
|
18
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default generateRandomNumber;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import capabilities from '../clientCapabilities';
|
|
2
|
+
|
|
3
|
+
const storageUtil = {
|
|
4
|
+
/**
|
|
5
|
+
* 获取本地存储数据
|
|
6
|
+
* @param key 数据key
|
|
7
|
+
* @returns string 存储的数据值
|
|
8
|
+
*/
|
|
9
|
+
get: (key: string): string => {
|
|
10
|
+
if (capabilities.localStorage) {
|
|
11
|
+
const v = localStorage.getItem(key);
|
|
12
|
+
return v === null ? '' : v;
|
|
13
|
+
}
|
|
14
|
+
if (capabilities.wxStorage) {
|
|
15
|
+
const v = wx.getStorageSync(key);
|
|
16
|
+
return typeof v === 'object' ? JSON.stringify(v) : String(v);
|
|
17
|
+
}
|
|
18
|
+
return '';
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default storageUtil;
|
|
@@ -5,15 +5,20 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export const obj2QueryString = (params: any) => {
|
|
7
7
|
const queryString = Object.keys(params)
|
|
8
|
-
.map(
|
|
9
|
-
(
|
|
10
|
-
|
|
8
|
+
.map((key) => {
|
|
9
|
+
if (typeof params[key] === 'object') {
|
|
10
|
+
return `${encodeURIComponent(key)}=${encodeURIComponent(
|
|
11
|
+
JSON.stringify(params[key]),
|
|
12
|
+
)}`;
|
|
13
|
+
}
|
|
14
|
+
return `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`;
|
|
15
|
+
})
|
|
11
16
|
.join('&');
|
|
12
17
|
return queryString;
|
|
13
18
|
};
|
|
14
19
|
|
|
15
20
|
/**
|
|
16
|
-
* 将url参数进行编码转换
|
|
21
|
+
* 将url参数进行编码转换(解码)
|
|
17
22
|
* @param queryStr 待处理url参数
|
|
18
23
|
* @returns
|
|
19
24
|
*/
|
|
@@ -45,7 +50,7 @@ export const getSearchObj = (url: string) => {
|
|
|
45
50
|
|
|
46
51
|
/**
|
|
47
52
|
* 移除URL指定参数
|
|
48
|
-
* @param url url地址
|
|
53
|
+
* @param url 待处理的url地址
|
|
49
54
|
* @param paramsToRemove 需要移除的参数列表
|
|
50
55
|
* @returns 处理后的url
|
|
51
56
|
*/
|
|
@@ -76,3 +81,23 @@ export const removeURLParameters = (
|
|
|
76
81
|
|
|
77
82
|
return result;
|
|
78
83
|
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 往url地址添加参数
|
|
87
|
+
* @param url 待处理的url地址
|
|
88
|
+
* @param params 待添加的参数数据
|
|
89
|
+
*/
|
|
90
|
+
export const addUrlParameters = (
|
|
91
|
+
url: string,
|
|
92
|
+
params: Record<any, any>,
|
|
93
|
+
): string => {
|
|
94
|
+
const paramsString = Object.keys(params)
|
|
95
|
+
.map((key) => {
|
|
96
|
+
if (typeof params[key] === 'object') {
|
|
97
|
+
return `${key}=${JSON.stringify(params[key])}`;
|
|
98
|
+
}
|
|
99
|
+
return `${key}=${params[key]}`;
|
|
100
|
+
})
|
|
101
|
+
.join('&');
|
|
102
|
+
return url + (url.indexOf('?') !== -1 ? '&' : '?') + paramsString;
|
|
103
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* getSceneCode.js
|
|
3
|
+
* params: 弹窗配置参数
|
|
4
|
+
* sceneCode: 组件直接传入的 sceneCode
|
|
5
|
+
* urlParam:url 参数
|
|
6
|
+
* pageData:页面数据中配置的参数
|
|
7
|
+
* modalInstId:弹窗实例 id,用于区分是一个弹窗实例,还是一个页面
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
type getSceneCodeFn = (options: {
|
|
11
|
+
params?: {
|
|
12
|
+
sceneCode?: string;
|
|
13
|
+
};
|
|
14
|
+
sceneCode?: string;
|
|
15
|
+
urlParam?: {
|
|
16
|
+
sceneCode?: string;
|
|
17
|
+
};
|
|
18
|
+
pageData?: {
|
|
19
|
+
chooseSceneObjec?: {
|
|
20
|
+
sceneCode?: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
modalInstId?: number | string;
|
|
24
|
+
}) => string;
|
|
25
|
+
|
|
26
|
+
const getSceneCode: getSceneCodeFn = (options) => {
|
|
27
|
+
const {
|
|
28
|
+
params: modalParams,
|
|
29
|
+
sceneCode: propsSceneCode,
|
|
30
|
+
urlParam,
|
|
31
|
+
pageData,
|
|
32
|
+
modalInstId,
|
|
33
|
+
} = options;
|
|
34
|
+
let newSceneCode = '';
|
|
35
|
+
if (modalInstId) {
|
|
36
|
+
newSceneCode =
|
|
37
|
+
modalParams?.sceneCode ||
|
|
38
|
+
propsSceneCode ||
|
|
39
|
+
pageData?.chooseSceneObjec?.sceneCode ||
|
|
40
|
+
'';
|
|
41
|
+
} else {
|
|
42
|
+
newSceneCode =
|
|
43
|
+
urlParam?.sceneCode ||
|
|
44
|
+
propsSceneCode ||
|
|
45
|
+
pageData?.chooseSceneObjec?.sceneCode ||
|
|
46
|
+
'';
|
|
47
|
+
}
|
|
48
|
+
return newSceneCode || '';
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default getSceneCode;
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Context } from './Context/context';
|
|
3
|
-
import {
|
|
4
|
-
getAllForm,
|
|
5
|
-
getBoframerOwnForms,
|
|
6
|
-
getBOFramerOwnFormValues,
|
|
7
|
-
getFieldsValue,
|
|
8
|
-
getFormByCompId,
|
|
9
|
-
getOwnFormValues,
|
|
10
|
-
updateNodeChildren,
|
|
11
|
-
} from './formUtils';
|
|
1
|
+
import { updateNodeChildren } from './formUtils';
|
|
12
2
|
|
|
13
3
|
const toBool = (v: string | boolean, defaultValue?: any) => {
|
|
14
4
|
let val = v;
|
|
15
|
-
if ([null, undefined].includes(val) && defaultValue !== undefined) {
|
|
5
|
+
if ([null, undefined].includes(val as any) && defaultValue !== undefined) {
|
|
16
6
|
val = defaultValue;
|
|
17
7
|
}
|
|
18
8
|
|
|
@@ -35,8 +25,6 @@ export interface ToolsContext {
|
|
|
35
25
|
}
|
|
36
26
|
|
|
37
27
|
export const useTool = (refs: Record<string, any>, context: ToolsContext) => {
|
|
38
|
-
const { refs: renderRefs } = useContext(Context);
|
|
39
|
-
|
|
40
28
|
const { addToAwaitQueue } = context;
|
|
41
29
|
|
|
42
30
|
const asyncGetValue = (id: string, stateName?: string) => {
|
|
@@ -207,157 +195,6 @@ export const useTool = (refs: Record<string, any>, context: ToolsContext) => {
|
|
|
207
195
|
}
|
|
208
196
|
});
|
|
209
197
|
|
|
210
|
-
/**
|
|
211
|
-
* 获取当前表单值
|
|
212
|
-
*/
|
|
213
|
-
const getFormValue = async (compId: string): Promise<any> => {
|
|
214
|
-
// 为了兼容动态渲染引擎,表单不存在 就返回空对象
|
|
215
|
-
if (!refs[compId]) return Promise.resolve({});
|
|
216
|
-
|
|
217
|
-
// 表单的情况 可能是循环容器
|
|
218
|
-
if (refs[compId].compName === 'Form') {
|
|
219
|
-
const forms = getFormByCompId(compId, refs);
|
|
220
|
-
return getFieldsValue(forms, (form) => {
|
|
221
|
-
return form?.getFieldsValue?.();
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (refs[compId].compName === 'BOFramer') {
|
|
226
|
-
return getBOFramerOwnFormValues(
|
|
227
|
-
{
|
|
228
|
-
refs,
|
|
229
|
-
renderRefs,
|
|
230
|
-
compId,
|
|
231
|
-
},
|
|
232
|
-
(form) => form?.getFieldsValue?.(),
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
return Promise.reject(
|
|
237
|
-
new Error('该组件不支持使用getFormValues获取表单数据'),
|
|
238
|
-
);
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* 验证并取值
|
|
243
|
-
* @param compId
|
|
244
|
-
*/
|
|
245
|
-
const validateForm = async (compId: string): Promise<any> => {
|
|
246
|
-
// 为了兼容动态渲染引擎,表单不存在 就返回空对象
|
|
247
|
-
if (!refs[compId]) return Promise.resolve({});
|
|
248
|
-
|
|
249
|
-
// 表单的情况 可能是循环容器
|
|
250
|
-
if (refs[compId].compName === 'Form') {
|
|
251
|
-
const forms = getFormByCompId(compId, refs);
|
|
252
|
-
return getFieldsValue(forms, (form) => {
|
|
253
|
-
return form?.validateFormAndScroll?.();
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
if (refs[compId].compName === 'BOFramer') {
|
|
258
|
-
return getBOFramerOwnFormValues(
|
|
259
|
-
{
|
|
260
|
-
refs,
|
|
261
|
-
renderRefs,
|
|
262
|
-
compId,
|
|
263
|
-
},
|
|
264
|
-
(form) => form?.validateFormAndScroll?.(),
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
return Promise.reject(
|
|
268
|
-
new Error('该组件不支持使用getFormValues获取表单数据'),
|
|
269
|
-
);
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* 重置表单值
|
|
274
|
-
* @param compId
|
|
275
|
-
*/
|
|
276
|
-
const resetForm = (compId: string) => {
|
|
277
|
-
if (!refs[compId]) return;
|
|
278
|
-
const compName = refs[compId].compName;
|
|
279
|
-
if (compName === 'BOFramer') {
|
|
280
|
-
const forms = getBoframerOwnForms({
|
|
281
|
-
currentRefs: refs,
|
|
282
|
-
renderRefs,
|
|
283
|
-
compId,
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
forms.forEach((form) => {
|
|
287
|
-
form?.resetFields?.();
|
|
288
|
-
});
|
|
289
|
-
} else {
|
|
290
|
-
const forms = getFormByCompId(compId, refs);
|
|
291
|
-
// 支持循环容器中的表单重置
|
|
292
|
-
(Array.isArray(forms) ? forms : [forms]).forEach((form) =>
|
|
293
|
-
form?.resetFields(),
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* 设置表单值
|
|
300
|
-
* @param compId 组件id
|
|
301
|
-
* @param formValues 表单值
|
|
302
|
-
*/
|
|
303
|
-
const setFormValues = (
|
|
304
|
-
compId: string,
|
|
305
|
-
formValues: Record<string, any> = {},
|
|
306
|
-
) => {
|
|
307
|
-
if (!refs[compId]) return;
|
|
308
|
-
const compName = refs[compId].compName;
|
|
309
|
-
|
|
310
|
-
if (compName === 'BOFramer') {
|
|
311
|
-
const forms = getBoframerOwnForms({
|
|
312
|
-
currentRefs: refs,
|
|
313
|
-
renderRefs,
|
|
314
|
-
compId,
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
forms.forEach((form) => {
|
|
318
|
-
form?.setFieldsValue(formValues);
|
|
319
|
-
});
|
|
320
|
-
} else {
|
|
321
|
-
refs[compId]?.setFieldsValue?.(formValues);
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* 校验并获取所有表单值
|
|
327
|
-
* 获取页面下的所有表单,包含当前页面下的表单、页面容器下的表单、业务组件下的表单。
|
|
328
|
-
* 不包含所有弹窗类组件的表单数据
|
|
329
|
-
*/
|
|
330
|
-
const validateAllForm = () =>
|
|
331
|
-
getOwnFormValues({ currentRefs: refs, renderRefs }, (form) =>
|
|
332
|
-
form.validateFormAndScroll?.(false),
|
|
333
|
-
);
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* 获取所有表单值 但不校验
|
|
337
|
-
* 获取页面下的所有表单,包含当前页面下的表单、页面容器下的表单、业务组件下的表单。
|
|
338
|
-
* 不包含所有弹窗类组件的表单数据
|
|
339
|
-
*/
|
|
340
|
-
const getAllFormValues = () =>
|
|
341
|
-
getOwnFormValues({ currentRefs: refs, renderRefs }, (form) =>
|
|
342
|
-
form.getFieldsValue?.(),
|
|
343
|
-
);
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* 重置所有表单
|
|
347
|
-
* 获取页面下的所有表单,包含当前页面下的表单、页面容器下的表单、业务组件下的表单。
|
|
348
|
-
* 不包含所有弹窗类组件的表单数据
|
|
349
|
-
*/
|
|
350
|
-
const resetAllForm = () => {
|
|
351
|
-
const forms = getAllForm({
|
|
352
|
-
currentRefs: refs,
|
|
353
|
-
renderRefs,
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
forms.forEach((form) => {
|
|
357
|
-
form.resetFields();
|
|
358
|
-
});
|
|
359
|
-
};
|
|
360
|
-
|
|
361
198
|
/**
|
|
362
199
|
* 获取联动数据值
|
|
363
200
|
* @param attrDataMap 静态数据
|
|
@@ -413,15 +250,8 @@ export const useTool = (refs: Record<string, any>, context: ToolsContext) => {
|
|
|
413
250
|
callComponentMethod,
|
|
414
251
|
setDisabled,
|
|
415
252
|
getDisabled,
|
|
416
|
-
getFormValue,
|
|
417
|
-
validateForm,
|
|
418
|
-
resetForm,
|
|
419
253
|
clearValue,
|
|
420
|
-
setFormValues,
|
|
421
254
|
asyncCallComponentMethod,
|
|
422
|
-
validateAllForm,
|
|
423
|
-
getAllFormValues,
|
|
424
|
-
resetAllForm,
|
|
425
255
|
updateNodeChildren,
|
|
426
256
|
getTriggerRelDataSource,
|
|
427
257
|
};
|