@lingxiteam/ebe-utils 0.1.6 → 0.1.9
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/constants.js
CHANGED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { version } from '@/utils/version';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
interface CompatConfigParams {
|
|
5
|
+
createdEditorVersion: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const useCompatConfig = (params: CompatConfigParams) => {
|
|
9
|
+
const { createdEditorVersion } = params;
|
|
10
|
+
|
|
11
|
+
const lessThanV331 = useMemo(() => {
|
|
12
|
+
const versionStr = version.getMainVersion(createdEditorVersion);
|
|
13
|
+
if (versionStr) {
|
|
14
|
+
return version.isLessThan(versionStr, '3.3.1');
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
}, [createdEditorVersion]);
|
|
18
|
+
|
|
19
|
+
const lessThanV381 = useMemo(() => {
|
|
20
|
+
const versionStr = version.getMainVersion(createdEditorVersion);
|
|
21
|
+
if (versionStr) {
|
|
22
|
+
return version.isLessThan(versionStr, '3.8.1');
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}, [createdEditorVersion]);
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
isFormCompat: lessThanV331,
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 是否开启联动规则
|
|
32
|
+
*/
|
|
33
|
+
openLinkageRule: true,
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 表单重置到默认值
|
|
37
|
+
*/
|
|
38
|
+
resetFormToDefaultValue: !lessThanV381,
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 指令兼容
|
|
42
|
+
*/
|
|
43
|
+
cmd: {
|
|
44
|
+
/**
|
|
45
|
+
* 小于3.8.1 自定义代码块里面更改数据源后,触发页面绑定数据的刷新,大于等于3.8.1不刷新
|
|
46
|
+
*/
|
|
47
|
+
customActionCodeNotUpdateData: !lessThanV381,
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 指令作用域只生效在同层级,3.8.1之后生效
|
|
51
|
+
*/
|
|
52
|
+
peerScope: !lessThanV381,
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 阻止onClick冒泡的指令
|
|
56
|
+
*/
|
|
57
|
+
stopPropagation: !lessThanV331 ? ['onClick'] : undefined,
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 调用任意页面自定义事件兼容(3.3.1 之后 使用engineRelation 去调用任意页面事件,否则都使用lcdapi去调用)
|
|
61
|
+
*/
|
|
62
|
+
compatCallCustomPageFunc: lessThanV331,
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* pc设置表单值动作是否需要触发表单值变化回掉(3.3.1之前 不论绑定数据源还是不绑定数据源都触发)
|
|
66
|
+
*/
|
|
67
|
+
setFieldsValueToOnValuesChange: lessThanV331,
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 3.3.1后业务组件和页面容器动作控制隐藏,通过dsiplay none
|
|
71
|
+
*/
|
|
72
|
+
boFramePageViewVisibleDisplayNone: !lessThanV331,
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 3.8.1 后表格所有动作只操作内部数据,不上报到数据源
|
|
76
|
+
*/
|
|
77
|
+
tableUpdateInnerDataSource: !lessThanV381,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 2个数组位数对齐
|
|
3
|
+
* @param list1
|
|
4
|
+
* @param list2
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
const repairArr = (list1: number[], list2: number[]) => {
|
|
8
|
+
if (list1.length === list2.length) {
|
|
9
|
+
return [list1, list2];
|
|
10
|
+
}
|
|
11
|
+
if (list1.length > list2.length) {
|
|
12
|
+
list2.push(...new Array(list1.length - list2.length).fill(0));
|
|
13
|
+
return [list1, list2];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
list1.push(...new Array(list2.length - list1.length).fill(0));
|
|
17
|
+
return [list1, list2];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 分割"." 获取number数组
|
|
22
|
+
* @param version
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
const splitVersionNumber = (version: string) => {
|
|
26
|
+
return version
|
|
27
|
+
.split('.')
|
|
28
|
+
.map((v) => parseInt(v.replace(/[^\d]/g, ''), 10) || 0);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const version = {
|
|
32
|
+
/**
|
|
33
|
+
* version1 是否小于 version2
|
|
34
|
+
* @param version1
|
|
35
|
+
* @param version2
|
|
36
|
+
*/
|
|
37
|
+
isLessThan(version1: string, version2: string) {
|
|
38
|
+
if (
|
|
39
|
+
!version1 ||
|
|
40
|
+
!version2 ||
|
|
41
|
+
typeof version1 !== 'string' ||
|
|
42
|
+
typeof version2 !== 'string'
|
|
43
|
+
) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let splitVerArr1 = splitVersionNumber(version1);
|
|
48
|
+
let splitVerArr2 = splitVersionNumber(version2);
|
|
49
|
+
|
|
50
|
+
[splitVerArr1, splitVerArr2] = repairArr(splitVerArr1, splitVerArr2);
|
|
51
|
+
|
|
52
|
+
for (let index = 0; index < splitVerArr1.length; index += 1) {
|
|
53
|
+
const ver1 = splitVerArr1[index];
|
|
54
|
+
const ver2 = splitVerArr2[index];
|
|
55
|
+
// 如果版本号中同位版本一致则继续比较下一位,否则返回比较结果
|
|
56
|
+
if (ver1 !== ver2) {
|
|
57
|
+
return ver1 < ver2;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 获取主版本号
|
|
65
|
+
* @param str 版本号
|
|
66
|
+
*/
|
|
67
|
+
getMainVersion(str?: string): string {
|
|
68
|
+
if (!str) {
|
|
69
|
+
return '';
|
|
70
|
+
}
|
|
71
|
+
let versions: string[] = [];
|
|
72
|
+
if (typeof str === 'string') {
|
|
73
|
+
versions = str.split('.');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (versions.length !== 4) {
|
|
77
|
+
return '';
|
|
78
|
+
}
|
|
79
|
+
return versions.slice(0, 3).join('.');
|
|
80
|
+
},
|
|
81
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingxiteam/ebe-utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@babel/types": "^7.12.12",
|
|
20
20
|
"cac": "^6.7.14",
|
|
21
21
|
"fs-extra": "9.x",
|
|
22
|
-
"@lingxiteam/ebe": "0.1.
|
|
22
|
+
"@lingxiteam/ebe": "0.1.9"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|