@jiangood/springboot-admin-starter 0.0.3 → 0.0.5
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/config/dist/config.js +32 -0
- package/config/dist/index.js +0 -1
- package/config/dist/plugins/form-plugin.js +2 -2
- package/package.json +12 -10
- package/src/forms/demoForm.jsx +5 -5
- package/src/framework/components/DownloadFileButton.jsx +2 -2
- package/src/framework/components/Ellipsis.jsx +2 -2
- package/src/framework/components/LinkButton.d.ts +4 -4
- package/src/framework/components/LinkButton.jsx +6 -9
- package/src/framework/components/Page/index.jsx +2 -2
- package/src/framework/components/PageLoading.tsx +27 -0
- package/src/framework/components/ProTable/components/ToolBar/index.jsx +6 -7
- package/src/framework/components/ProTable/index.d.ts +5 -1
- package/src/framework/components/ProTable/index.jsx +4 -6
- package/src/framework/components/ProTable/index.less +0 -1
- package/src/framework/components/ValueType/registry.jsx +9 -20
- package/src/framework/components/{index.js → index.ts} +2 -10
- package/src/framework/components/system/ButtonList.jsx +35 -0
- package/src/framework/components/system/HasPerm.tsx +14 -0
- package/src/framework/components/system/index.tsx +29 -0
- package/src/framework/components/view/ViewBooleanEnableDisable.tsx +20 -0
- package/src/framework/components/view/ViewEllipsis.jsx +2 -2
- package/src/framework/components/view/ViewFile.jsx +1 -2
- package/src/framework/components/view/ViewImage.jsx +2 -3
- package/src/framework/components/view/ViewText.tsx +16 -0
- package/src/framework/components/view/{index.js → index.ts} +0 -2
- package/src/framework/field-components/FieldBoolean.d.ts +13 -0
- package/src/framework/field-components/FieldBoolean.jsx +76 -0
- package/src/framework/field-components/FieldDate.d.ts +25 -0
- package/src/framework/field-components/FieldDate.jsx +109 -0
- package/src/framework/field-components/FieldDateRange.d.ts +6 -0
- package/src/framework/field-components/FieldDateRange.jsx +101 -0
- package/src/framework/field-components/FieldDictSelect.d.ts +13 -0
- package/src/framework/field-components/FieldDictSelect.jsx +16 -0
- package/src/framework/field-components/FieldEditor.d.ts +10 -0
- package/src/framework/field-components/FieldEditor.jsx +58 -0
- package/src/framework/field-components/FieldPercent.d.ts +12 -0
- package/src/framework/field-components/FieldPercent.jsx +27 -0
- package/src/framework/field-components/FieldRemoteSelect.d.ts +13 -0
- package/src/framework/field-components/FieldRemoteSelect.jsx +87 -0
- package/src/framework/field-components/FieldRemoteSelectMultiple.d.ts +13 -0
- package/src/framework/field-components/FieldRemoteSelectMultiple.jsx +86 -0
- package/src/framework/field-components/FieldRemoteSelectMultipleInline.d.ts +20 -0
- package/src/framework/field-components/FieldRemoteSelectMultipleInline.jsx +86 -0
- package/src/framework/field-components/FieldRemoteTree.d.ts +21 -0
- package/src/framework/field-components/FieldRemoteTree.jsx +45 -0
- package/src/framework/field-components/FieldRemoteTreeCascader.d.ts +23 -0
- package/src/framework/field-components/FieldRemoteTreeCascader.jsx +61 -0
- package/src/framework/field-components/FieldRemoteTreeSelect.d.ts +17 -0
- package/src/framework/field-components/FieldRemoteTreeSelect.jsx +67 -0
- package/src/framework/field-components/FieldRemoteTreeSelectMultiple.d.ts +17 -0
- package/src/framework/field-components/FieldRemoteTreeSelectMultiple.jsx +68 -0
- package/src/framework/field-components/FieldSysOrgTree.d.ts +12 -0
- package/src/framework/field-components/FieldSysOrgTree.jsx +23 -0
- package/src/framework/field-components/FieldSysOrgTreeSelect.d.ts +12 -0
- package/src/framework/field-components/FieldSysOrgTreeSelect.jsx +23 -0
- package/src/framework/field-components/FieldTable.d.ts +17 -0
- package/src/framework/field-components/FieldTable.jsx +108 -0
- package/src/framework/{components/field/select/FieldTableSelect/index.d.ts → field-components/FieldTableSelect.d.ts} +4 -14
- package/src/framework/field-components/FieldTableSelect.jsx +59 -0
- package/src/framework/{components/field/upload → field-components}/FieldUploadFile.d.ts +0 -1
- package/src/framework/{components/field/upload → field-components}/FieldUploadFile.jsx +5 -9
- package/src/framework/field-components/index.ts +20 -0
- package/src/framework/{components/OrgTree.jsx → field-components/system/OrgTree.tsx} +8 -7
- package/src/framework/{components/RoleTree.jsx → field-components/system/RoleTree.tsx} +3 -3
- package/src/framework/field-components/system/index.ts +2 -0
- package/src/framework/index.ts +5 -0
- package/src/framework/pages/LoginPage.d.ts +11 -0
- package/src/framework/pages/LoginPage.jsx +136 -0
- package/src/{pages/login.less → framework/pages/LoginPage.less} +1 -1
- package/src/framework/pages/index.ts +1 -0
- package/src/framework/utils/ArrUtils.ts +229 -0
- package/src/framework/utils/ColorsUtils.ts +378 -0
- package/src/framework/utils/{date.js → DateUtils.ts} +69 -69
- package/src/framework/utils/DeviceUtils.ts +46 -0
- package/src/framework/utils/DomUtils.ts +50 -0
- package/src/framework/utils/EventBusUtils.ts +143 -0
- package/src/framework/utils/MessageUtils.tsx +182 -0
- package/src/framework/utils/ObjectUtils.ts +113 -0
- package/src/framework/utils/StorageUtils.ts +67 -0
- package/src/framework/utils/StringUtils.ts +410 -0
- package/src/framework/utils/TreeUtils.ts +248 -0
- package/src/framework/utils/UrlUtils.ts +152 -0
- package/src/framework/utils/UuidUtils.ts +88 -0
- package/src/framework/utils/ValidateUtils.ts +28 -0
- package/src/framework/utils/index.ts +16 -0
- package/src/framework/utils/system/DictUtils.ts +97 -0
- package/src/framework/utils/system/FormRegistryUtils.ts +77 -0
- package/src/framework/utils/system/HttpUtils.ts +246 -0
- package/src/framework/utils/system/PageUtils.ts +153 -0
- package/src/framework/utils/system/PermUtils.ts +79 -0
- package/src/framework/utils/system/SysUtils.ts +97 -0
- package/src/framework/utils/system/ThemeUtils.ts +27 -0
- package/src/framework/utils/system/index.ts +7 -0
- package/src/framework/view-components/ViewBoolean.jsx +4 -0
- package/src/framework/view-components/index.js +3 -0
- package/src/layouts/PageRender.jsx +2 -2
- package/src/layouts/admin/HeaderRight.jsx +9 -9
- package/src/layouts/admin/TabPageRender.jsx +2 -2
- package/src/layouts/admin/index.jsx +27 -40
- package/src/layouts/admin/index.less +2 -1
- package/src/layouts/index.jsx +30 -38
- package/src/layouts/index.less +0 -21
- package/src/loading.jsx +2 -2
- package/src/{components → pages/flowable}/InstanceInfo.jsx +5 -4
- package/src/pages/flowable/design/customTranslate/customTranslate.js +16 -0
- package/src/pages/flowable/design/customTranslate/translations-properties-panel.js +10 -0
- package/src/pages/flowable/design/customTranslate/translations.js +144 -0
- package/src/pages/flowable/design/descriptors/flowable.json +1109 -0
- package/src/pages/flowable/design/index.jsx +61 -234
- package/src/pages/flowable/design/provider/FlowablePropertiesProvider.js +75 -0
- package/src/pages/flowable/design/provider/index.js +6 -0
- package/src/pages/flowable/design/provider/properties/ConditionDesign.jsx +175 -0
- package/src/pages/flowable/design/provider/properties/ConditionProps.jsx +76 -0
- package/src/pages/flowable/design/provider/properties/DelegateExpressionProps.js +54 -0
- package/src/pages/flowable/design/provider/properties/FormProps.js +55 -0
- package/src/pages/flowable/design/provider/properties/MultiInstanceProps.js +100 -0
- package/src/pages/flowable/design/provider/properties/UserTaskForm.jsx +48 -0
- package/src/pages/flowable/design/provider/properties/utils.jsx +35 -0
- package/src/pages/flowable/index.jsx +28 -69
- package/src/pages/flowable/monitor/definition.jsx +87 -0
- package/src/pages/flowable/monitor/instance/index.jsx +177 -0
- package/src/pages/flowable/monitor/instance/view.jsx +102 -0
- package/src/pages/flowable/monitor/task.jsx +93 -0
- package/src/pages/flowable/task/form.jsx +5 -5
- package/src/pages/flowable/task/index.jsx +5 -5
- package/src/pages/flowable/test/index.jsx +13 -10
- package/src/pages/index.jsx +8 -13
- package/src/pages/login.jsx +4 -129
- package/src/pages/{api/doc.jsx → system/api/ApiDoc.jsx} +56 -47
- package/src/pages/system/api/index.jsx +268 -0
- package/src/pages/system/api/perm.jsx +69 -0
- package/src/pages/system/config/index.jsx +3 -3
- package/src/pages/system/dict/Dict.jsx +2 -3
- package/src/pages/system/dict/DictItem.jsx +5 -5
- package/src/pages/system/file/index.jsx +13 -5
- package/src/pages/{job → system/job}/index.jsx +124 -39
- package/src/pages/system/log/index.jsx +3 -3
- package/src/pages/system/org/index.jsx +11 -12
- package/src/pages/system/role/index.jsx +11 -11
- package/src/pages/system/role/perm.jsx +8 -8
- package/src/pages/system/sysManual/index.jsx +6 -6
- package/src/pages/system/user/UserPerm.jsx +7 -42
- package/src/pages/system/user/index.jsx +13 -17
- package/src/pages/test.jsx +188 -3
- package/src/pages/ureport/index.jsx +4 -4
- package/src/pages/userCenter/ChangePassword.jsx +3 -4
- package/src/pages/userCenter/index.jsx +2 -2
- package/src/pages/userCenter/manual.jsx +3 -7
- package/src/pages/userCenter/message.jsx +5 -5
- package/config/dist/config.local.js +0 -23
- package/src/components/InstanceStatusInfo.jsx +0 -79
- package/src/components/StreamLog.jsx +0 -27
- package/src/components/flow/BpmnUtils.js +0 -85
- package/src/components/flow/customTranslate/customTranslate.js +0 -19
- package/src/components/flow/customTranslate/translations.js +0 -79
- package/src/components/flow/design/form/ConditionForm.jsx +0 -316
- package/src/components/flow/design/form/ServiceTaskForm.jsx +0 -55
- package/src/components/flow/design/form/TimerEventDefinitionForm.jsx +0 -62
- package/src/components/flow/design/form/UserTaskForm.jsx +0 -211
- package/src/components/flow/design/palette.js +0 -39
- package/src/components/monitor/AllDefinition.jsx +0 -46
- package/src/components/monitor/AllInstance.jsx +0 -76
- package/src/forms/driverForm.jsx +0 -18
- package/src/framework/components/ButtonList.jsx +0 -91
- package/src/framework/components/Echarts/index.d.ts +0 -10
- package/src/framework/components/Echarts/index.jsx +0 -49
- package/src/framework/components/EditTable/index.d.ts +0 -11
- package/src/framework/components/EditTable/index.jsx +0 -85
- package/src/framework/components/FieldRemoteTree.jsx +0 -20
- package/src/framework/components/HasPerm.jsx +0 -18
- package/src/framework/components/ImageView.d.ts +0 -12
- package/src/framework/components/ImageView.jsx +0 -64
- package/src/framework/components/MsgBox.jsx +0 -180
- package/src/framework/components/PageLoading.jsx +0 -31
- package/src/framework/components/Panel/index.d.ts +0 -11
- package/src/framework/components/Panel/index.jsx +0 -24
- package/src/framework/components/Panel/index.less +0 -0
- package/src/framework/components/field/FieldAutoTime/index.tsx +0 -46
- package/src/framework/components/field/FieldBoolean/index.tsx +0 -92
- package/src/framework/components/field/FieldEditTable/index.d.ts +0 -13
- package/src/framework/components/field/FieldEditTable/index.jsx +0 -103
- package/src/framework/components/field/FieldEditTable/index.less +0 -29
- package/src/framework/components/field/FieldEditor.jsx +0 -48
- package/src/framework/components/field/FieldFileBase64/index.d.ts +0 -15
- package/src/framework/components/field/FieldFileBase64/index.jsx +0 -23
- package/src/framework/components/field/FieldImageBase64/index.d.ts +0 -15
- package/src/framework/components/field/FieldImageBase64/index.jsx +0 -22
- package/src/framework/components/field/FieldInput.jsx +0 -13
- package/src/framework/components/field/FieldOrgTree/index.tsx +0 -45
- package/src/framework/components/field/FieldPassword.jsx +0 -11
- package/src/framework/components/field/FieldProps.ts +0 -19
- package/src/framework/components/field/FieldRemoteTreeCascader.jsx +0 -75
- package/src/framework/components/field/FieldRemoteTreeCheckable.jsx +0 -81
- package/src/framework/components/field/FieldRemoteTreeMultipleSelect.jsx +0 -100
- package/src/framework/components/field/FieldRemoteTreeSelect.jsx +0 -82
- package/src/framework/components/field/FieldSelectPosition/index.tsx +0 -85
- package/src/framework/components/field/FieldTree.jsx +0 -45
- package/src/framework/components/field/dict/index.tsx +0 -110
- package/src/framework/components/field/flat-multiple-select/index.d.ts +0 -4
- package/src/framework/components/field/flat-multiple-select/index.jsx +0 -116
- package/src/framework/components/field/flat-multiple-select/index.less +0 -12
- package/src/framework/components/field/flat-select/index.d.ts +0 -4
- package/src/framework/components/field/flat-select/index.jsx +0 -107
- package/src/framework/components/field/flat-select/index.less +0 -12
- package/src/framework/components/field/index.js +0 -33
- package/src/framework/components/field/input-number-percent/index.d.ts +0 -11
- package/src/framework/components/field/input-number-percent/index.jsx +0 -28
- package/src/framework/components/field/select/FieldSelect/index.d.ts +0 -39
- package/src/framework/components/field/select/FieldSelect/index.jsx +0 -156
- package/src/framework/components/field/select/FieldTableSelect/index.jsx +0 -155
- package/src/framework/components/field/select/index.jsx +0 -2
- package/src/framework/components/field/switch-y-n/index.d.ts +0 -11
- package/src/framework/components/field/switch-y-n/index.jsx +0 -31
- package/src/framework/components/field/text/index.tsx +0 -7
- package/src/framework/components/field/time/DatePickerString.tsx +0 -37
- package/src/framework/components/field/time/DateTimePickerString.tsx +0 -42
- package/src/framework/components/field/time/FieldDateRange.d.ts +0 -9
- package/src/framework/components/field/time/FieldDateRange.jsx +0 -49
- package/src/framework/components/field/time/HHmmPickerString.tsx +0 -42
- package/src/framework/components/field/time/MonthPickerString.tsx +0 -45
- package/src/framework/components/field/time/TimePickerTool.ts +0 -14
- package/src/framework/components/field/time/YearPickerString.tsx +0 -41
- package/src/framework/components/field/time/YearQuarterString.tsx +0 -38
- package/src/framework/components/field/time/index.tsx +0 -7
- package/src/framework/components/field/upload/FieldUploadCropImage/index.d.ts +0 -22
- package/src/framework/components/field/upload/FieldUploadCropImage/index.jsx +0 -11
- package/src/framework/components/field/upload/FieldUploadImage.d.ts +0 -7
- package/src/framework/components/field/upload/FieldUploadImage.jsx +0 -16
- package/src/framework/components/field/upload/index.jsx +0 -3
- package/src/framework/components/system.jsx +0 -29
- package/src/framework/components/view/ViewBoolean.jsx +0 -15
- package/src/framework/components/view/ViewBooleanEnableDisable.jsx +0 -16
- package/src/framework/components/view/ViewText.jsx +0 -9
- package/src/framework/index.js +0 -3
- package/src/framework/system/dict.js +0 -88
- package/src/framework/system/formRegistry.js +0 -58
- package/src/framework/system/http.jsx +0 -290
- package/src/framework/system/index.js +0 -13
- package/src/framework/system/page.js +0 -109
- package/src/framework/system/permission.js +0 -44
- package/src/framework/system/sys.js +0 -60
- package/src/framework/system/theme.js +0 -17
- package/src/framework/utils/arr.js +0 -118
- package/src/framework/utils/browser.js +0 -24
- package/src/framework/utils/color.js +0 -269
- package/src/framework/utils/debounce.js +0 -33
- package/src/framework/utils/dom.js +0 -16
- package/src/framework/utils/eventBus.js +0 -70
- package/src/framework/utils/html.js +0 -13
- package/src/framework/utils/index.js +0 -17
- package/src/framework/utils/obj.js +0 -72
- package/src/framework/utils/storage.js +0 -37
- package/src/framework/utils/str.js +0 -297
- package/src/framework/utils/tree.js +0 -175
- package/src/framework/utils/uid.js +0 -76
- package/src/framework/utils/url.js +0 -84
- package/src/framework/utils/validate.js +0 -9
- package/src/pages/api/accessLog/index.jsx +0 -108
- package/src/pages/api/accountResource/index.jsx +0 -149
- package/src/pages/api/index.jsx +0 -163
- package/src/pages/api/resource.jsx +0 -18
- package/src/pages/flowable/instance/view.jsx +0 -13
- package/src/pages/flowable/monitor.jsx +0 -106
- package/src/pages/flowable/test/form.jsx +0 -31
- package/src/pages/job/logList.jsx +0 -100
- package/src/pages/job/status.jsx +0 -84
- /package/src/framework/components/{ButtonList.d.ts → system/ButtonList.d.ts} +0 -0
- /package/src/framework/{components/EditTable/index.less → field-components/FieldTable.less} +0 -0
- /package/src/framework/{components/view → view-components}/ViewPassword.jsx +0 -0
- /package/src/{index.js → index.ts} +0 -0
- /package/src/{components/flow → pages/flowable}/design/contextPad.js +0 -0
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 于安全地获取深度嵌套的对象属性的值
|
|
3
|
-
* 如果属性链中的任何一级为 undefined 或 null,get 函数会返回一个默认值,而不是抛出错误。
|
|
4
|
-
*
|
|
5
|
-
* const obj = { 'a': [{ 'b': { 'c': 3 } }] };
|
|
6
|
-
*
|
|
7
|
-
* const value = get(obj, 'a[0].b.c');
|
|
8
|
-
*
|
|
9
|
-
* @param obj
|
|
10
|
-
* @param path
|
|
11
|
-
* @param defaultValue
|
|
12
|
-
*/
|
|
13
|
-
export function get(obj, path, defaultValue = undefined){
|
|
14
|
-
|
|
15
|
-
const pathArray = Array.isArray(path) ? path : path.split('.');
|
|
16
|
-
let result = obj;
|
|
17
|
-
|
|
18
|
-
// 遍历路径
|
|
19
|
-
for (const segment of pathArray) {
|
|
20
|
-
if (result == null) {
|
|
21
|
-
return defaultValue;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// 尝试访问属性
|
|
25
|
-
result = result[segment];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// 如果结果还是 null 或 undefined,则返回默认值
|
|
29
|
-
return result != null ? result : defaultValue;
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export class ObjUtil {
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 复制对象属性
|
|
38
|
-
* 如果目标对象的属性存在才复制
|
|
39
|
-
* @param source
|
|
40
|
-
* @param target
|
|
41
|
-
*/
|
|
42
|
-
static copyPropertyIfPresent(source, target){
|
|
43
|
-
if (!source || !target || typeof source !== 'object' || typeof target !== 'object') {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const keys = Object.keys(target)
|
|
48
|
-
for (let key of keys) {
|
|
49
|
-
if(Object.hasOwn(source,key)){
|
|
50
|
-
let value = source[key];
|
|
51
|
-
target[key] = value
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
static copyProperty(source, target){
|
|
58
|
-
if (!source || !target || typeof source !== 'object' || typeof target !== 'object') {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const keys = Object.keys(target)
|
|
63
|
-
for (let key of keys) {
|
|
64
|
-
let value = source[key];
|
|
65
|
-
if(value !== undefined){
|
|
66
|
-
target[key] = value
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {DateUtil} from "./date";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const ENCRYPT = false;
|
|
5
|
-
|
|
6
|
-
export const StorageUtil = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
get(key, defaultValue = null) {
|
|
10
|
-
let v = localStorage.getItem(key);
|
|
11
|
-
if (v == null) {
|
|
12
|
-
v = defaultValue;
|
|
13
|
-
}else {
|
|
14
|
-
const item = JSON.parse(v);
|
|
15
|
-
v = item.data
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return v
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
set(key, value) {
|
|
23
|
-
if(value == null){
|
|
24
|
-
localStorage.removeItem(key)
|
|
25
|
-
}
|
|
26
|
-
const item = {
|
|
27
|
-
createTime: DateUtil.now(),
|
|
28
|
-
data: value
|
|
29
|
-
}
|
|
30
|
-
const dataStr = JSON.stringify(item)
|
|
31
|
-
localStorage.setItem(key, dataStr)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
export const StrUtil = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
removePrefix(str, ch){
|
|
6
|
-
if(str != null && str.startsWith(ch)){
|
|
7
|
-
return str.substring(ch.length)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return str;
|
|
11
|
-
},
|
|
12
|
-
removeSuffix(str, ch){
|
|
13
|
-
if(str != null && str.endsWith(ch)){
|
|
14
|
-
return str.substring(0,str.length - ch.length)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return str;
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
random(length){
|
|
21
|
-
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
22
|
-
let result = '';
|
|
23
|
-
for (let i = 0; i < length; i++) {
|
|
24
|
-
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
nullText(key){
|
|
31
|
-
return (key || '') + "未定义"
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 包含
|
|
37
|
-
* @param subStr
|
|
38
|
-
* @returns {boolean}
|
|
39
|
-
*/
|
|
40
|
-
contains(str, subStr) {
|
|
41
|
-
if (!str) {
|
|
42
|
-
return false
|
|
43
|
-
}
|
|
44
|
-
return str.includes(subStr);
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* 判断字符串出现的个数
|
|
50
|
-
* @param subStr
|
|
51
|
-
*/
|
|
52
|
-
count(str, subStr) {
|
|
53
|
-
if (str == null || str.length == 0) {
|
|
54
|
-
return 0;
|
|
55
|
-
}
|
|
56
|
-
let count = 0;
|
|
57
|
-
let index = 0;
|
|
58
|
-
|
|
59
|
-
while (true) {
|
|
60
|
-
index = str.indexOf(subStr, index);
|
|
61
|
-
if (index === -1) {
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
count++;
|
|
65
|
-
index += subStr.length;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return count;
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* 将字符串的首字母转换为大写
|
|
74
|
-
*/
|
|
75
|
-
capitalize(str) {
|
|
76
|
-
if (str == null) {
|
|
77
|
-
return str
|
|
78
|
-
}
|
|
79
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* 颠倒字符串的顺序
|
|
84
|
-
* @param str
|
|
85
|
-
* @returns {*}
|
|
86
|
-
*/
|
|
87
|
-
reverse(str) {
|
|
88
|
-
if (str == null) {
|
|
89
|
-
return str;
|
|
90
|
-
}
|
|
91
|
-
return str.split('').reverse().join('');
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* 截取字符串, 如果不包含,则原样返回
|
|
96
|
-
* @param source
|
|
97
|
-
* @param str
|
|
98
|
-
* @returns {string|null}
|
|
99
|
-
*/
|
|
100
|
-
subAfter(source, str) {
|
|
101
|
-
if (source == null) {
|
|
102
|
-
return source;
|
|
103
|
-
}
|
|
104
|
-
const index = source.indexOf(str)
|
|
105
|
-
return index === -1 ? source : source.substring(index + 1);
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
subAfterLast(source, str) {
|
|
109
|
-
if (source == null) {
|
|
110
|
-
return source;
|
|
111
|
-
}
|
|
112
|
-
const index = source.lastIndexOf(str)
|
|
113
|
-
return index === -1 ? source : source.substring(index + 1);
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
subBefore(s, sub) {
|
|
117
|
-
if (s == null) {
|
|
118
|
-
return s;
|
|
119
|
-
}
|
|
120
|
-
const index = s.indexOf(sub)
|
|
121
|
-
return index === -1 ? s : s.substring(0, index);
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* 混淆
|
|
126
|
-
* @param str
|
|
127
|
-
* @returns {*}
|
|
128
|
-
*/
|
|
129
|
-
obfuscateString(str) {
|
|
130
|
-
if (str == null) {
|
|
131
|
-
return str
|
|
132
|
-
}
|
|
133
|
-
return str.split('').map(char => char + 1).join('');
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* 补零
|
|
139
|
-
* @param input 输入字符串说数字等
|
|
140
|
-
* @param totalLen 总长度,不狗
|
|
141
|
-
* @param padChar
|
|
142
|
-
* @returns {string}
|
|
143
|
-
*/
|
|
144
|
-
pad(input, totalLen, padChar = '0') {
|
|
145
|
-
if (input == null) {
|
|
146
|
-
return padChar.repeat(totalLen)
|
|
147
|
-
}
|
|
148
|
-
var str = String(input);
|
|
149
|
-
var zerosNeeded = totalLen - str.length;
|
|
150
|
-
if (zerosNeeded > 0) {
|
|
151
|
-
str = padChar.repeat(zerosNeeded) + str;
|
|
152
|
-
}
|
|
153
|
-
return str;
|
|
154
|
-
},
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* 加密
|
|
159
|
-
* @param str
|
|
160
|
-
* @returns {string}
|
|
161
|
-
*/
|
|
162
|
-
encrypt(str) {
|
|
163
|
-
if (str == null) {
|
|
164
|
-
return str
|
|
165
|
-
}
|
|
166
|
-
let encrypted = '';
|
|
167
|
-
for (let i = 0; i < str.length; i++) {
|
|
168
|
-
let charCode = str.charCodeAt(i);
|
|
169
|
-
charCode += 1;
|
|
170
|
-
encrypted += ('00' + charCode.toString(16)).slice(-4); // 转换为四位的十六进制表示
|
|
171
|
-
}
|
|
172
|
-
return encrypted;
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
decrypt(hexString) {
|
|
177
|
-
if (hexString == null) {
|
|
178
|
-
return hexString;
|
|
179
|
-
}
|
|
180
|
-
let decrypted = '';
|
|
181
|
-
for (let i = 0; i < hexString.length; i += 4) {
|
|
182
|
-
let hexCharCode = hexString.substr(i, 4);
|
|
183
|
-
let charCode = parseInt(hexCharCode, 16); // 将十六进制转换为十进制
|
|
184
|
-
charCode -= 1
|
|
185
|
-
decrypted += String.fromCharCode(charCode);
|
|
186
|
-
}
|
|
187
|
-
return decrypted;
|
|
188
|
-
},
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* 类似String.length, 区别在与中文字符占2位宽
|
|
193
|
-
* 获取字符串长度,英文字符 长度1,中文字符长度2
|
|
194
|
-
* @param {*} str
|
|
195
|
-
*/
|
|
196
|
-
getWidth(str) {
|
|
197
|
-
if (str == null || str.length === 0) {
|
|
198
|
-
return 0
|
|
199
|
-
}
|
|
200
|
-
return str.split('').reduce((pre, cur) => {
|
|
201
|
-
const charCode = cur.charCodeAt(0);
|
|
202
|
-
if (charCode >= 0 && charCode <= 128) {
|
|
203
|
-
return pre + 1;
|
|
204
|
-
}
|
|
205
|
-
return pre + 2;
|
|
206
|
-
}, 0);
|
|
207
|
-
},
|
|
208
|
-
|
|
209
|
-
cutByWidth(str, maxWidth) {
|
|
210
|
-
let showLength = 0;
|
|
211
|
-
return str.split('').reduce((pre, cur) => {
|
|
212
|
-
const charCode = cur.charCodeAt(0);
|
|
213
|
-
if (charCode >= 0 && charCode <= 128) {
|
|
214
|
-
showLength += 1;
|
|
215
|
-
} else {
|
|
216
|
-
showLength += 2;
|
|
217
|
-
}
|
|
218
|
-
if (showLength <= maxWidth) {
|
|
219
|
-
return pre + cur;
|
|
220
|
-
}
|
|
221
|
-
return pre;
|
|
222
|
-
}, '');
|
|
223
|
-
},
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
*
|
|
228
|
-
* @param str
|
|
229
|
-
* @param len 字符长度,注:中文字符算2
|
|
230
|
-
* @constructor
|
|
231
|
-
*/
|
|
232
|
-
ellipsis(str, len, suffix = '...') {
|
|
233
|
-
if (str == null) {
|
|
234
|
-
return str;
|
|
235
|
-
}
|
|
236
|
-
if (!this.isStr(str)) {
|
|
237
|
-
return str;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// 快速判断2倍
|
|
241
|
-
if (str.length * 2 < len) {
|
|
242
|
-
return str
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
const fullLength = this.getWidth(str);
|
|
246
|
-
let isTooLong = fullLength > len;
|
|
247
|
-
|
|
248
|
-
if (!isTooLong) {
|
|
249
|
-
return str;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
return this.cutByWidth(str, len) + suffix;
|
|
253
|
-
},
|
|
254
|
-
|
|
255
|
-
isStr(value) {
|
|
256
|
-
return typeof value === "string"
|
|
257
|
-
},
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
// 转驼峰
|
|
261
|
-
toCamelCase(str, firstLower = true) {
|
|
262
|
-
let result = str.replace(/\_(\w)/g, function (all, letter) {
|
|
263
|
-
return letter.toUpperCase();
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
if (firstLower) {
|
|
267
|
-
result = result.substring(0, 1).toLowerCase() + result.substring(1);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return result;
|
|
271
|
-
},
|
|
272
|
-
|
|
273
|
-
toUnderlineCase(name) {
|
|
274
|
-
if (name == null) {
|
|
275
|
-
return null;
|
|
276
|
-
}
|
|
277
|
-
let result = name.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
278
|
-
if (result.startsWith('_')) {
|
|
279
|
-
result = result.substring(1);
|
|
280
|
-
}
|
|
281
|
-
return result;
|
|
282
|
-
},
|
|
283
|
-
|
|
284
|
-
equalsIgnoreCase(a, b) {
|
|
285
|
-
if (a != null && b != null) {
|
|
286
|
-
if (a === b) {
|
|
287
|
-
return true;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (a.toLowerCase() === b.toLowerCase()) {
|
|
291
|
-
return true;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
return false;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
// 数据结构 - tree
|
|
2
|
-
|
|
3
|
-
// 为方便起见,默认 3个字段 id, pid, children
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {ArrUtil} from "./arr";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function treeToList(tree, level = 1, result = []) {
|
|
10
|
-
for (const node of tree) {
|
|
11
|
-
const newNode = {...node, level: level};
|
|
12
|
-
result.push(newNode);
|
|
13
|
-
|
|
14
|
-
if (node.children && node.children.length > 0) {
|
|
15
|
-
treeToList(node.children, level + 1, result);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return result;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export const TreeUtil = {
|
|
24
|
-
treeToList,
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
* @param tree
|
|
29
|
-
* @param level -1所有
|
|
30
|
-
*/
|
|
31
|
-
findKeysByLevel(tree, level) {
|
|
32
|
-
const list = this.treeToList(tree)
|
|
33
|
-
if (level === -1) {
|
|
34
|
-
return list.filter(t => t.level === level).map(t => t.id)
|
|
35
|
-
}
|
|
36
|
-
return list.filter(t => t.level === level).map(t => t.id)
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 将数组转换为树
|
|
41
|
-
* @param list
|
|
42
|
-
* @param idKey
|
|
43
|
-
* @param pidKey
|
|
44
|
-
* @returns {*[]}
|
|
45
|
-
*/
|
|
46
|
-
buildTree(list, idKey = 'id', pidKey = 'pid') {
|
|
47
|
-
const map = {};
|
|
48
|
-
for (let i = 0; i < list.length; i++) {
|
|
49
|
-
const node = list[i];
|
|
50
|
-
let id = node[idKey];
|
|
51
|
-
map[id] = node;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const root = [];
|
|
55
|
-
for (let i = 0; i < list.length; i++) {
|
|
56
|
-
const node = list[i];
|
|
57
|
-
let pid = node[pidKey];
|
|
58
|
-
let parent = map[pid]
|
|
59
|
-
if (parent) {
|
|
60
|
-
if (parent.children == null) {
|
|
61
|
-
parent.children = []
|
|
62
|
-
}
|
|
63
|
-
parent.children.push(node)
|
|
64
|
-
} else {
|
|
65
|
-
root.push(node)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return root;
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// 遍历树节点
|
|
74
|
-
walk(tree, callback) {
|
|
75
|
-
// 遍历当前层级的节点
|
|
76
|
-
for (let i = 0; i < tree.length; i++) {
|
|
77
|
-
const node = tree[i];
|
|
78
|
-
callback(node); // 执行回调函数
|
|
79
|
-
|
|
80
|
-
// 遍历子节点
|
|
81
|
-
if (node.children && node.children.length > 0) {
|
|
82
|
-
this.walk(node.children, callback);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
findByKey(key, list, keyName = "id") {
|
|
88
|
-
for (let item of list) {
|
|
89
|
-
if (item[keyName] === key) {
|
|
90
|
-
return item;
|
|
91
|
-
}
|
|
92
|
-
if (item.children && item.children.length) {
|
|
93
|
-
const rs = this.findByKey(key, item.children, keyName)
|
|
94
|
-
if (rs) {
|
|
95
|
-
return rs;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
findByKeyList(treeData, keyList) {
|
|
103
|
-
const itemList = [];
|
|
104
|
-
this.traverseTree(treeData, (item) => {
|
|
105
|
-
const key = item.key || item.id;
|
|
106
|
-
|
|
107
|
-
if (ArrUtil.contains(keyList, key)) {
|
|
108
|
-
itemList.push(item);
|
|
109
|
-
}
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
return itemList;
|
|
113
|
-
},
|
|
114
|
-
// id, pid
|
|
115
|
-
getSimpleList(treeNodeList) {
|
|
116
|
-
const buffer = [];
|
|
117
|
-
|
|
118
|
-
if (treeNodeList != null) {
|
|
119
|
-
treeNodeList.forEach((t) => {
|
|
120
|
-
buffer.push(t);
|
|
121
|
-
TreeUtil.getChild(t, buffer);
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
return buffer;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
, getChild(treeNode, buffer) {
|
|
128
|
-
if (treeNode.children != null && treeNode.children.length > 0) {
|
|
129
|
-
treeNode.children.forEach((c) => {
|
|
130
|
-
buffer.push(c);
|
|
131
|
-
TreeUtil.getChild(c, buffer);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
return buffer;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
, getKeyList(tree, value) {
|
|
138
|
-
const list = TreeUtil.getSimpleList(tree);
|
|
139
|
-
|
|
140
|
-
const map = {};
|
|
141
|
-
list.forEach((t) => {
|
|
142
|
-
map[t.key || t.id] = t;
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
const t = map[value];
|
|
146
|
-
if (t == null) {
|
|
147
|
-
return [];
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const keys = [t.key || t.id];
|
|
151
|
-
let parent = map[t.parentKey || t.pid];
|
|
152
|
-
while (parent != null) {
|
|
153
|
-
keys.push(parent.key || t.id);
|
|
154
|
-
parent = map[parent.parentKey || t.pid];
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return keys.reverse();
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Based on the work of https://github.com/jchook/uuid-random
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
let
|
|
6
|
-
buf,
|
|
7
|
-
bufIdx = 0
|
|
8
|
-
const hexBytes = new Array(256)
|
|
9
|
-
|
|
10
|
-
// Pre-calculate toString(16) for speed
|
|
11
|
-
for (let i = 0; i < 256; i++) {
|
|
12
|
-
hexBytes[ i ] = (i + 0x100).toString(16).substring(1)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Use best available PRNG
|
|
16
|
-
const randomBytes = (() => {
|
|
17
|
-
// Node & Browser support
|
|
18
|
-
const lib = typeof crypto !== 'undefined'
|
|
19
|
-
? crypto
|
|
20
|
-
: (
|
|
21
|
-
typeof window !== 'undefined'
|
|
22
|
-
? window.crypto || window.msCrypto
|
|
23
|
-
: void 0
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
if (lib !== void 0) {
|
|
27
|
-
if (lib.randomBytes !== void 0) {
|
|
28
|
-
return lib.randomBytes
|
|
29
|
-
}
|
|
30
|
-
if (lib.getRandomValues !== void 0) {
|
|
31
|
-
return n => {
|
|
32
|
-
const bytes = new Uint8Array(n)
|
|
33
|
-
lib.getRandomValues(bytes)
|
|
34
|
-
return bytes
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return n => {
|
|
40
|
-
const r = []
|
|
41
|
-
for (let i = n; i > 0; i--) {
|
|
42
|
-
r.push(Math.floor(Math.random() * 256))
|
|
43
|
-
}
|
|
44
|
-
return r
|
|
45
|
-
}
|
|
46
|
-
})()
|
|
47
|
-
|
|
48
|
-
// Buffer random numbers for speed
|
|
49
|
-
// Reduce memory usage by decreasing this number (min 16)
|
|
50
|
-
// or improve speed by increasing this number (try 16384)
|
|
51
|
-
const BUFFER_SIZE = 4096
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
export const UidUtil = {
|
|
56
|
-
uid () {
|
|
57
|
-
// Buffer some random bytes for speed
|
|
58
|
-
if (buf === void 0 || (bufIdx + 16 > BUFFER_SIZE)) {
|
|
59
|
-
bufIdx = 0
|
|
60
|
-
buf = randomBytes(BUFFER_SIZE)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const b = Array.prototype.slice.call(buf, bufIdx, (bufIdx += 16))
|
|
64
|
-
b[ 6 ] = (b[ 6 ] & 0x0f) | 0x40
|
|
65
|
-
b[ 8 ] = (b[ 8 ] & 0x3f) | 0x80
|
|
66
|
-
|
|
67
|
-
return hexBytes[ b[ 0 ] ] + hexBytes[ b[ 1 ] ]
|
|
68
|
-
+ hexBytes[ b[ 2 ] ] + hexBytes[ b[ 3 ] ] + '-'
|
|
69
|
-
+ hexBytes[ b[ 4 ] ] + hexBytes[ b[ 5 ] ] + '-'
|
|
70
|
-
+ hexBytes[ b[ 6 ] ] + hexBytes[ b[ 7 ] ] + '-'
|
|
71
|
-
+ hexBytes[ b[ 8 ] ] + hexBytes[ b[ 9 ] ] + '-'
|
|
72
|
-
+ hexBytes[ b[ 10 ] ] + hexBytes[ b[ 11 ] ]
|
|
73
|
-
+ hexBytes[ b[ 12 ] ] + hexBytes[ b[ 13 ] ]
|
|
74
|
-
+ hexBytes[ b[ 14 ] ] + hexBytes[ b[ 15 ] ]
|
|
75
|
-
}
|
|
76
|
-
}
|