@jiangood/springboot-admin-starter 0.0.2 → 0.0.4

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 (266) hide show
  1. package/config/dist/config.js +32 -0
  2. package/config/dist/index.js +0 -1
  3. package/config/dist/plugins/form-plugin.js +2 -2
  4. package/package.json +12 -10
  5. package/src/forms/demoForm.jsx +5 -5
  6. package/src/framework/components/DownloadFileButton.jsx +2 -2
  7. package/src/framework/components/Ellipsis.jsx +2 -2
  8. package/src/framework/components/LinkButton.d.ts +4 -4
  9. package/src/framework/components/LinkButton.jsx +6 -9
  10. package/src/framework/components/Page/index.jsx +2 -2
  11. package/src/framework/components/PageLoading.tsx +27 -0
  12. package/src/framework/components/ProTable/components/ToolBar/index.jsx +6 -7
  13. package/src/framework/components/ProTable/index.d.ts +5 -1
  14. package/src/framework/components/ProTable/index.jsx +4 -6
  15. package/src/framework/components/ProTable/index.less +0 -1
  16. package/src/framework/components/ValueType/registry.jsx +9 -20
  17. package/src/framework/components/{index.js → index.ts} +2 -10
  18. package/src/framework/components/system/ButtonList.jsx +35 -0
  19. package/src/framework/components/system/HasPerm.tsx +14 -0
  20. package/src/framework/components/system/index.tsx +29 -0
  21. package/src/framework/components/view/ViewBooleanEnableDisable.tsx +20 -0
  22. package/src/framework/components/view/ViewEllipsis.jsx +2 -2
  23. package/src/framework/components/view/ViewFile.jsx +1 -2
  24. package/src/framework/components/view/ViewImage.jsx +2 -3
  25. package/src/framework/components/view/ViewText.tsx +16 -0
  26. package/src/framework/components/view/{index.js → index.ts} +0 -2
  27. package/src/framework/field-components/FieldBoolean.d.ts +13 -0
  28. package/src/framework/field-components/FieldBoolean.jsx +76 -0
  29. package/src/framework/field-components/FieldDate.d.ts +25 -0
  30. package/src/framework/field-components/FieldDate.jsx +109 -0
  31. package/src/framework/field-components/FieldDateRange.d.ts +6 -0
  32. package/src/framework/field-components/FieldDateRange.jsx +101 -0
  33. package/src/framework/field-components/FieldDictSelect.d.ts +13 -0
  34. package/src/framework/field-components/FieldDictSelect.jsx +16 -0
  35. package/src/framework/field-components/FieldEditor.d.ts +10 -0
  36. package/src/framework/field-components/FieldEditor.jsx +58 -0
  37. package/src/framework/field-components/FieldPercent.d.ts +12 -0
  38. package/src/framework/field-components/FieldPercent.jsx +27 -0
  39. package/src/framework/field-components/FieldRemoteSelect.d.ts +13 -0
  40. package/src/framework/field-components/FieldRemoteSelect.jsx +87 -0
  41. package/src/framework/field-components/FieldRemoteSelectMultiple.d.ts +13 -0
  42. package/src/framework/field-components/FieldRemoteSelectMultiple.jsx +86 -0
  43. package/src/framework/field-components/FieldRemoteSelectMultipleInline.d.ts +20 -0
  44. package/src/framework/field-components/FieldRemoteSelectMultipleInline.jsx +86 -0
  45. package/src/framework/field-components/FieldRemoteTree.d.ts +21 -0
  46. package/src/framework/field-components/FieldRemoteTree.jsx +45 -0
  47. package/src/framework/field-components/FieldRemoteTreeCascader.d.ts +23 -0
  48. package/src/framework/field-components/FieldRemoteTreeCascader.jsx +61 -0
  49. package/src/framework/field-components/FieldRemoteTreeSelect.d.ts +17 -0
  50. package/src/framework/field-components/FieldRemoteTreeSelect.jsx +67 -0
  51. package/src/framework/field-components/FieldRemoteTreeSelectMultiple.d.ts +17 -0
  52. package/src/framework/field-components/FieldRemoteTreeSelectMultiple.jsx +68 -0
  53. package/src/framework/field-components/FieldSysOrgTree.d.ts +12 -0
  54. package/src/framework/field-components/FieldSysOrgTree.jsx +23 -0
  55. package/src/framework/field-components/FieldSysOrgTreeSelect.d.ts +12 -0
  56. package/src/framework/field-components/FieldSysOrgTreeSelect.jsx +23 -0
  57. package/src/framework/{components/field/FieldEditTable/index.d.ts → field-components/FieldTable.d.ts} +5 -2
  58. package/src/framework/{components/field/FieldEditTable/index.jsx → field-components/FieldTable.jsx} +29 -21
  59. package/src/framework/{components/field/select/FieldTableSelect/index.d.ts → field-components/FieldTableSelect.d.ts} +4 -14
  60. package/src/framework/field-components/FieldTableSelect.jsx +59 -0
  61. package/src/framework/{components/field/upload → field-components}/FieldUploadFile.d.ts +0 -1
  62. package/src/framework/{components/field/upload → field-components}/FieldUploadFile.jsx +5 -9
  63. package/src/framework/field-components/index.ts +20 -0
  64. package/src/framework/{components/OrgTree.jsx → field-components/system/OrgTree.tsx} +8 -7
  65. package/src/framework/{components/RoleTree.jsx → field-components/system/RoleTree.tsx} +3 -3
  66. package/src/framework/field-components/system/index.ts +2 -0
  67. package/src/framework/index.ts +4 -0
  68. package/src/framework/utils/ArrUtils.ts +229 -0
  69. package/src/framework/utils/ColorsUtils.ts +378 -0
  70. package/src/framework/utils/{date.js → DateUtils.ts} +69 -69
  71. package/src/framework/utils/DeviceUtils.ts +46 -0
  72. package/src/framework/utils/DomUtils.ts +50 -0
  73. package/src/framework/utils/EventBusUtils.ts +143 -0
  74. package/src/framework/utils/MessageUtils.tsx +182 -0
  75. package/src/framework/utils/ObjectUtils.ts +113 -0
  76. package/src/framework/utils/StorageUtils.ts +67 -0
  77. package/src/framework/utils/StringUtils.ts +410 -0
  78. package/src/framework/utils/TreeUtils.ts +248 -0
  79. package/src/framework/utils/UrlUtils.ts +152 -0
  80. package/src/framework/utils/UuidUtils.ts +88 -0
  81. package/src/framework/utils/ValidateUtils.ts +28 -0
  82. package/src/framework/utils/index.ts +16 -0
  83. package/src/framework/utils/system/DictUtils.ts +97 -0
  84. package/src/framework/utils/system/FormRegistryUtils.ts +77 -0
  85. package/src/framework/utils/system/HttpUtils.ts +246 -0
  86. package/src/framework/utils/system/PageUtils.ts +153 -0
  87. package/src/framework/utils/system/PermUtils.ts +79 -0
  88. package/src/framework/utils/system/SysUtils.ts +97 -0
  89. package/src/framework/utils/system/ThemeUtils.ts +27 -0
  90. package/src/framework/utils/system/index.ts +7 -0
  91. package/src/framework/view-components/ViewBoolean.jsx +4 -0
  92. package/src/framework/view-components/index.js +3 -0
  93. package/src/layouts/PageRender.jsx +2 -2
  94. package/src/layouts/admin/HeaderRight.jsx +9 -9
  95. package/src/layouts/admin/TabPageRender.jsx +2 -2
  96. package/src/layouts/admin/index.jsx +27 -40
  97. package/src/layouts/admin/index.less +2 -1
  98. package/src/layouts/index.jsx +30 -38
  99. package/src/layouts/index.less +0 -21
  100. package/src/loading.jsx +2 -2
  101. package/src/{components → pages/flowable}/InstanceInfo.jsx +5 -4
  102. package/src/pages/flowable/design/customTranslate/customTranslate.js +16 -0
  103. package/src/pages/flowable/design/customTranslate/translations-properties-panel.js +10 -0
  104. package/src/pages/flowable/design/customTranslate/translations.js +144 -0
  105. package/src/pages/flowable/design/descriptors/flowable.json +1109 -0
  106. package/src/pages/flowable/design/index.jsx +61 -234
  107. package/src/pages/flowable/design/provider/FlowablePropertiesProvider.js +75 -0
  108. package/src/pages/flowable/design/provider/index.js +6 -0
  109. package/src/pages/flowable/design/provider/properties/ConditionDesign.jsx +175 -0
  110. package/src/pages/flowable/design/provider/properties/ConditionProps.jsx +76 -0
  111. package/src/pages/flowable/design/provider/properties/DelegateExpressionProps.js +54 -0
  112. package/src/pages/flowable/design/provider/properties/FormProps.js +55 -0
  113. package/src/pages/flowable/design/provider/properties/MultiInstanceProps.js +100 -0
  114. package/src/pages/flowable/design/provider/properties/UserTaskForm.jsx +48 -0
  115. package/src/pages/flowable/design/provider/properties/utils.jsx +35 -0
  116. package/src/pages/flowable/index.jsx +28 -69
  117. package/src/pages/flowable/monitor/definition.jsx +87 -0
  118. package/src/pages/flowable/monitor/instance/index.jsx +177 -0
  119. package/src/pages/flowable/monitor/instance/view.jsx +102 -0
  120. package/src/pages/flowable/monitor/task.jsx +93 -0
  121. package/src/pages/flowable/task/form.jsx +5 -5
  122. package/src/pages/flowable/task/index.jsx +5 -5
  123. package/src/pages/flowable/test/index.jsx +13 -10
  124. package/src/pages/index.jsx +8 -13
  125. package/src/pages/login.jsx +8 -8
  126. package/src/pages/{api/doc.jsx → system/api/ApiDoc.jsx} +56 -47
  127. package/src/pages/system/api/index.jsx +268 -0
  128. package/src/pages/system/api/perm.jsx +69 -0
  129. package/src/pages/system/config/index.jsx +3 -3
  130. package/src/pages/system/dict/Dict.jsx +2 -3
  131. package/src/pages/system/dict/DictItem.jsx +5 -5
  132. package/src/pages/system/file/index.jsx +13 -5
  133. package/src/pages/{job → system/job}/index.jsx +124 -39
  134. package/src/pages/system/log/index.jsx +3 -3
  135. package/src/pages/system/org/index.jsx +11 -12
  136. package/src/pages/system/role/index.jsx +11 -11
  137. package/src/pages/system/role/perm.jsx +8 -8
  138. package/src/pages/system/sysManual/index.jsx +6 -6
  139. package/src/pages/system/user/UserPerm.jsx +7 -42
  140. package/src/pages/system/user/index.jsx +13 -17
  141. package/src/pages/test.jsx +188 -3
  142. package/src/pages/ureport/index.jsx +4 -4
  143. package/src/pages/userCenter/ChangePassword.jsx +3 -4
  144. package/src/pages/userCenter/index.jsx +2 -2
  145. package/src/pages/userCenter/manual.jsx +3 -7
  146. package/src/pages/userCenter/message.jsx +5 -5
  147. package/config/dist/config.local.js +0 -23
  148. package/src/components/InstanceStatusInfo.jsx +0 -79
  149. package/src/components/StreamLog.jsx +0 -27
  150. package/src/components/flow/BpmnUtils.js +0 -85
  151. package/src/components/flow/customTranslate/customTranslate.js +0 -19
  152. package/src/components/flow/customTranslate/translations.js +0 -79
  153. package/src/components/flow/design/form/ConditionForm.jsx +0 -316
  154. package/src/components/flow/design/form/ServiceTaskForm.jsx +0 -55
  155. package/src/components/flow/design/form/TimerEventDefinitionForm.jsx +0 -62
  156. package/src/components/flow/design/form/UserTaskForm.jsx +0 -211
  157. package/src/components/flow/design/palette.js +0 -39
  158. package/src/components/monitor/AllDefinition.jsx +0 -46
  159. package/src/components/monitor/AllInstance.jsx +0 -76
  160. package/src/forms/driverForm.jsx +0 -18
  161. package/src/framework/components/ButtonList.jsx +0 -91
  162. package/src/framework/components/Echarts/index.d.ts +0 -10
  163. package/src/framework/components/Echarts/index.jsx +0 -49
  164. package/src/framework/components/EditTable/index.d.ts +0 -11
  165. package/src/framework/components/EditTable/index.jsx +0 -85
  166. package/src/framework/components/FieldRemoteTree.jsx +0 -20
  167. package/src/framework/components/HasPerm.jsx +0 -18
  168. package/src/framework/components/ImageView.d.ts +0 -12
  169. package/src/framework/components/ImageView.jsx +0 -64
  170. package/src/framework/components/MsgBox.jsx +0 -180
  171. package/src/framework/components/PageLoading.jsx +0 -31
  172. package/src/framework/components/Panel/index.d.ts +0 -11
  173. package/src/framework/components/Panel/index.jsx +0 -24
  174. package/src/framework/components/Panel/index.less +0 -0
  175. package/src/framework/components/field/FieldAutoTime/index.tsx +0 -46
  176. package/src/framework/components/field/FieldBoolean/index.tsx +0 -92
  177. package/src/framework/components/field/FieldEditTable/index.less +0 -29
  178. package/src/framework/components/field/FieldEditor.jsx +0 -48
  179. package/src/framework/components/field/FieldFileBase64/index.d.ts +0 -15
  180. package/src/framework/components/field/FieldFileBase64/index.jsx +0 -23
  181. package/src/framework/components/field/FieldImageBase64/index.d.ts +0 -15
  182. package/src/framework/components/field/FieldImageBase64/index.jsx +0 -22
  183. package/src/framework/components/field/FieldInput.jsx +0 -13
  184. package/src/framework/components/field/FieldOrgTree/index.tsx +0 -45
  185. package/src/framework/components/field/FieldPassword.jsx +0 -11
  186. package/src/framework/components/field/FieldProps.ts +0 -19
  187. package/src/framework/components/field/FieldRemoteTreeCascader.jsx +0 -75
  188. package/src/framework/components/field/FieldRemoteTreeCheckable.jsx +0 -81
  189. package/src/framework/components/field/FieldRemoteTreeMultipleSelect.jsx +0 -100
  190. package/src/framework/components/field/FieldRemoteTreeSelect.jsx +0 -82
  191. package/src/framework/components/field/FieldSelectPosition/index.tsx +0 -85
  192. package/src/framework/components/field/FieldTree.jsx +0 -45
  193. package/src/framework/components/field/dict/index.tsx +0 -110
  194. package/src/framework/components/field/flat-multiple-select/index.d.ts +0 -4
  195. package/src/framework/components/field/flat-multiple-select/index.jsx +0 -116
  196. package/src/framework/components/field/flat-multiple-select/index.less +0 -12
  197. package/src/framework/components/field/flat-select/index.d.ts +0 -4
  198. package/src/framework/components/field/flat-select/index.jsx +0 -107
  199. package/src/framework/components/field/flat-select/index.less +0 -12
  200. package/src/framework/components/field/index.js +0 -33
  201. package/src/framework/components/field/input-number-percent/index.d.ts +0 -11
  202. package/src/framework/components/field/input-number-percent/index.jsx +0 -28
  203. package/src/framework/components/field/select/FieldSelect/index.d.ts +0 -39
  204. package/src/framework/components/field/select/FieldSelect/index.jsx +0 -156
  205. package/src/framework/components/field/select/FieldTableSelect/index.jsx +0 -155
  206. package/src/framework/components/field/select/index.jsx +0 -2
  207. package/src/framework/components/field/switch-y-n/index.d.ts +0 -11
  208. package/src/framework/components/field/switch-y-n/index.jsx +0 -31
  209. package/src/framework/components/field/text/index.tsx +0 -7
  210. package/src/framework/components/field/time/DatePickerString.tsx +0 -37
  211. package/src/framework/components/field/time/DateTimePickerString.tsx +0 -42
  212. package/src/framework/components/field/time/FieldDateRange.d.ts +0 -9
  213. package/src/framework/components/field/time/FieldDateRange.jsx +0 -49
  214. package/src/framework/components/field/time/HHmmPickerString.tsx +0 -42
  215. package/src/framework/components/field/time/MonthPickerString.tsx +0 -45
  216. package/src/framework/components/field/time/TimePickerTool.ts +0 -14
  217. package/src/framework/components/field/time/YearPickerString.tsx +0 -41
  218. package/src/framework/components/field/time/YearQuarterString.tsx +0 -38
  219. package/src/framework/components/field/time/index.tsx +0 -7
  220. package/src/framework/components/field/upload/FieldUploadCropImage/index.d.ts +0 -22
  221. package/src/framework/components/field/upload/FieldUploadCropImage/index.jsx +0 -11
  222. package/src/framework/components/field/upload/FieldUploadImage.d.ts +0 -7
  223. package/src/framework/components/field/upload/FieldUploadImage.jsx +0 -16
  224. package/src/framework/components/field/upload/index.jsx +0 -3
  225. package/src/framework/components/system.jsx +0 -29
  226. package/src/framework/components/view/ViewBoolean.jsx +0 -15
  227. package/src/framework/components/view/ViewBooleanEnableDisable.jsx +0 -16
  228. package/src/framework/components/view/ViewText.jsx +0 -9
  229. package/src/framework/index.js +0 -3
  230. package/src/framework/system/dict.js +0 -88
  231. package/src/framework/system/formRegistry.js +0 -58
  232. package/src/framework/system/http.jsx +0 -290
  233. package/src/framework/system/index.js +0 -13
  234. package/src/framework/system/page.js +0 -109
  235. package/src/framework/system/permission.js +0 -44
  236. package/src/framework/system/sys.js +0 -60
  237. package/src/framework/system/theme.js +0 -17
  238. package/src/framework/utils/arr.js +0 -118
  239. package/src/framework/utils/browser.js +0 -24
  240. package/src/framework/utils/color.js +0 -269
  241. package/src/framework/utils/debounce.js +0 -33
  242. package/src/framework/utils/dom.js +0 -16
  243. package/src/framework/utils/eventBus.js +0 -70
  244. package/src/framework/utils/html.js +0 -13
  245. package/src/framework/utils/index.js +0 -17
  246. package/src/framework/utils/obj.js +0 -72
  247. package/src/framework/utils/storage.js +0 -37
  248. package/src/framework/utils/str.js +0 -297
  249. package/src/framework/utils/tree.js +0 -175
  250. package/src/framework/utils/uid.js +0 -76
  251. package/src/framework/utils/url.js +0 -84
  252. package/src/framework/utils/validate.js +0 -9
  253. package/src/pages/api/accessLog/index.jsx +0 -108
  254. package/src/pages/api/accountResource/index.jsx +0 -149
  255. package/src/pages/api/index.jsx +0 -163
  256. package/src/pages/api/resource.jsx +0 -18
  257. package/src/pages/flowable/instance/view.jsx +0 -13
  258. package/src/pages/flowable/monitor.jsx +0 -106
  259. package/src/pages/flowable/test/form.jsx +0 -31
  260. package/src/pages/job/logList.jsx +0 -100
  261. package/src/pages/job/status.jsx +0 -84
  262. /package/src/framework/components/{ButtonList.d.ts → system/ButtonList.d.ts} +0 -0
  263. /package/src/framework/{components/EditTable/index.less → field-components/FieldTable.less} +0 -0
  264. /package/src/framework/{components/view → view-components}/ViewPassword.jsx +0 -0
  265. /package/src/{index.js → index.ts} +0 -0
  266. /package/src/{components/flow → pages/flowable}/design/contextPad.js +0 -0
@@ -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
- }
@@ -1,84 +0,0 @@
1
- import {StrUtil} from "./str";
2
-
3
- export const UrlUtil = {
4
- /**
5
- * 获取url的参数, 如果不传参数,则使用当前路径
6
- * @param url 字符串
7
- */
8
- getParams(url = null) {
9
- if (!url) {
10
- url = location.href
11
- }
12
-
13
- if (!StrUtil.contains(url, '?')) {
14
- return {}
15
- }
16
-
17
- const search = StrUtil.subAfter(url, '?')
18
-
19
-
20
- const params = new URLSearchParams(search);
21
-
22
- const result = {}
23
- for (const [key, value] of params.entries()) {
24
- result[key] = value;
25
- }
26
-
27
- return result
28
- },
29
-
30
- /**
31
- * 去掉参数的基础url
32
- * @param url
33
- */
34
- getPathname(url) {
35
- if (!url) {
36
- return null
37
- }
38
-
39
- return StrUtil.subBefore(url, '?')
40
- },
41
-
42
-
43
- /**
44
- * 将参数对象转换为 url中的
45
- * @param params
46
- */
47
- paramsToSearch(params) {
48
- if (!params) {
49
- return "";
50
- }
51
- const buffer = []
52
- for (let k in params) {
53
- let v = params[k]
54
- buffer.push(k + '=' + v);
55
- }
56
- return buffer.join('&')
57
- },
58
-
59
- setParam(url, key, value) {
60
- const p = this.getParams(url)
61
- p[key] = value;
62
- if (value == null) {
63
- delete p[key]
64
- }
65
- return this.getPathname(url) + '?' + this.paramsToSearch(p);
66
- },
67
-
68
- /**
69
- * @deprecated
70
- * @param url
71
- * @param key
72
- * @param value
73
- */
74
- replaceParam(url, key, value) {
75
- this.setParam(url, key, value)
76
- },
77
-
78
- join(path1, path2) {
79
- path1 = StrUtil.removeSuffix(path1,"/")
80
- path2 = StrUtil.removePrefix(path2,"/")
81
- let path = path1 + "/" + path2;
82
- return path;
83
- }
84
- }
@@ -1,9 +0,0 @@
1
-
2
- export const ValidateUtil = {
3
- isEmail(emailStr) {
4
- const reg = /^([\w+\.])+@\w+([.]\w+)+$/;
5
- return reg.test(emailStr)
6
- }
7
- }
8
-
9
-