@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.
Files changed (272) 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/field-components/FieldTable.d.ts +17 -0
  58. package/src/framework/field-components/FieldTable.jsx +108 -0
  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 +5 -0
  68. package/src/framework/pages/LoginPage.d.ts +11 -0
  69. package/src/framework/pages/LoginPage.jsx +136 -0
  70. package/src/{pages/login.less → framework/pages/LoginPage.less} +1 -1
  71. package/src/framework/pages/index.ts +1 -0
  72. package/src/framework/utils/ArrUtils.ts +229 -0
  73. package/src/framework/utils/ColorsUtils.ts +378 -0
  74. package/src/framework/utils/{date.js → DateUtils.ts} +69 -69
  75. package/src/framework/utils/DeviceUtils.ts +46 -0
  76. package/src/framework/utils/DomUtils.ts +50 -0
  77. package/src/framework/utils/EventBusUtils.ts +143 -0
  78. package/src/framework/utils/MessageUtils.tsx +182 -0
  79. package/src/framework/utils/ObjectUtils.ts +113 -0
  80. package/src/framework/utils/StorageUtils.ts +67 -0
  81. package/src/framework/utils/StringUtils.ts +410 -0
  82. package/src/framework/utils/TreeUtils.ts +248 -0
  83. package/src/framework/utils/UrlUtils.ts +152 -0
  84. package/src/framework/utils/UuidUtils.ts +88 -0
  85. package/src/framework/utils/ValidateUtils.ts +28 -0
  86. package/src/framework/utils/index.ts +16 -0
  87. package/src/framework/utils/system/DictUtils.ts +97 -0
  88. package/src/framework/utils/system/FormRegistryUtils.ts +77 -0
  89. package/src/framework/utils/system/HttpUtils.ts +246 -0
  90. package/src/framework/utils/system/PageUtils.ts +153 -0
  91. package/src/framework/utils/system/PermUtils.ts +79 -0
  92. package/src/framework/utils/system/SysUtils.ts +97 -0
  93. package/src/framework/utils/system/ThemeUtils.ts +27 -0
  94. package/src/framework/utils/system/index.ts +7 -0
  95. package/src/framework/view-components/ViewBoolean.jsx +4 -0
  96. package/src/framework/view-components/index.js +3 -0
  97. package/src/layouts/PageRender.jsx +2 -2
  98. package/src/layouts/admin/HeaderRight.jsx +9 -9
  99. package/src/layouts/admin/TabPageRender.jsx +2 -2
  100. package/src/layouts/admin/index.jsx +27 -40
  101. package/src/layouts/admin/index.less +2 -1
  102. package/src/layouts/index.jsx +30 -38
  103. package/src/layouts/index.less +0 -21
  104. package/src/loading.jsx +2 -2
  105. package/src/{components → pages/flowable}/InstanceInfo.jsx +5 -4
  106. package/src/pages/flowable/design/customTranslate/customTranslate.js +16 -0
  107. package/src/pages/flowable/design/customTranslate/translations-properties-panel.js +10 -0
  108. package/src/pages/flowable/design/customTranslate/translations.js +144 -0
  109. package/src/pages/flowable/design/descriptors/flowable.json +1109 -0
  110. package/src/pages/flowable/design/index.jsx +61 -234
  111. package/src/pages/flowable/design/provider/FlowablePropertiesProvider.js +75 -0
  112. package/src/pages/flowable/design/provider/index.js +6 -0
  113. package/src/pages/flowable/design/provider/properties/ConditionDesign.jsx +175 -0
  114. package/src/pages/flowable/design/provider/properties/ConditionProps.jsx +76 -0
  115. package/src/pages/flowable/design/provider/properties/DelegateExpressionProps.js +54 -0
  116. package/src/pages/flowable/design/provider/properties/FormProps.js +55 -0
  117. package/src/pages/flowable/design/provider/properties/MultiInstanceProps.js +100 -0
  118. package/src/pages/flowable/design/provider/properties/UserTaskForm.jsx +48 -0
  119. package/src/pages/flowable/design/provider/properties/utils.jsx +35 -0
  120. package/src/pages/flowable/index.jsx +28 -69
  121. package/src/pages/flowable/monitor/definition.jsx +87 -0
  122. package/src/pages/flowable/monitor/instance/index.jsx +177 -0
  123. package/src/pages/flowable/monitor/instance/view.jsx +102 -0
  124. package/src/pages/flowable/monitor/task.jsx +93 -0
  125. package/src/pages/flowable/task/form.jsx +5 -5
  126. package/src/pages/flowable/task/index.jsx +5 -5
  127. package/src/pages/flowable/test/index.jsx +13 -10
  128. package/src/pages/index.jsx +8 -13
  129. package/src/pages/login.jsx +4 -129
  130. package/src/pages/{api/doc.jsx → system/api/ApiDoc.jsx} +56 -47
  131. package/src/pages/system/api/index.jsx +268 -0
  132. package/src/pages/system/api/perm.jsx +69 -0
  133. package/src/pages/system/config/index.jsx +3 -3
  134. package/src/pages/system/dict/Dict.jsx +2 -3
  135. package/src/pages/system/dict/DictItem.jsx +5 -5
  136. package/src/pages/system/file/index.jsx +13 -5
  137. package/src/pages/{job → system/job}/index.jsx +124 -39
  138. package/src/pages/system/log/index.jsx +3 -3
  139. package/src/pages/system/org/index.jsx +11 -12
  140. package/src/pages/system/role/index.jsx +11 -11
  141. package/src/pages/system/role/perm.jsx +8 -8
  142. package/src/pages/system/sysManual/index.jsx +6 -6
  143. package/src/pages/system/user/UserPerm.jsx +7 -42
  144. package/src/pages/system/user/index.jsx +13 -17
  145. package/src/pages/test.jsx +188 -3
  146. package/src/pages/ureport/index.jsx +4 -4
  147. package/src/pages/userCenter/ChangePassword.jsx +3 -4
  148. package/src/pages/userCenter/index.jsx +2 -2
  149. package/src/pages/userCenter/manual.jsx +3 -7
  150. package/src/pages/userCenter/message.jsx +5 -5
  151. package/config/dist/config.local.js +0 -23
  152. package/src/components/InstanceStatusInfo.jsx +0 -79
  153. package/src/components/StreamLog.jsx +0 -27
  154. package/src/components/flow/BpmnUtils.js +0 -85
  155. package/src/components/flow/customTranslate/customTranslate.js +0 -19
  156. package/src/components/flow/customTranslate/translations.js +0 -79
  157. package/src/components/flow/design/form/ConditionForm.jsx +0 -316
  158. package/src/components/flow/design/form/ServiceTaskForm.jsx +0 -55
  159. package/src/components/flow/design/form/TimerEventDefinitionForm.jsx +0 -62
  160. package/src/components/flow/design/form/UserTaskForm.jsx +0 -211
  161. package/src/components/flow/design/palette.js +0 -39
  162. package/src/components/monitor/AllDefinition.jsx +0 -46
  163. package/src/components/monitor/AllInstance.jsx +0 -76
  164. package/src/forms/driverForm.jsx +0 -18
  165. package/src/framework/components/ButtonList.jsx +0 -91
  166. package/src/framework/components/Echarts/index.d.ts +0 -10
  167. package/src/framework/components/Echarts/index.jsx +0 -49
  168. package/src/framework/components/EditTable/index.d.ts +0 -11
  169. package/src/framework/components/EditTable/index.jsx +0 -85
  170. package/src/framework/components/FieldRemoteTree.jsx +0 -20
  171. package/src/framework/components/HasPerm.jsx +0 -18
  172. package/src/framework/components/ImageView.d.ts +0 -12
  173. package/src/framework/components/ImageView.jsx +0 -64
  174. package/src/framework/components/MsgBox.jsx +0 -180
  175. package/src/framework/components/PageLoading.jsx +0 -31
  176. package/src/framework/components/Panel/index.d.ts +0 -11
  177. package/src/framework/components/Panel/index.jsx +0 -24
  178. package/src/framework/components/Panel/index.less +0 -0
  179. package/src/framework/components/field/FieldAutoTime/index.tsx +0 -46
  180. package/src/framework/components/field/FieldBoolean/index.tsx +0 -92
  181. package/src/framework/components/field/FieldEditTable/index.d.ts +0 -13
  182. package/src/framework/components/field/FieldEditTable/index.jsx +0 -103
  183. package/src/framework/components/field/FieldEditTable/index.less +0 -29
  184. package/src/framework/components/field/FieldEditor.jsx +0 -48
  185. package/src/framework/components/field/FieldFileBase64/index.d.ts +0 -15
  186. package/src/framework/components/field/FieldFileBase64/index.jsx +0 -23
  187. package/src/framework/components/field/FieldImageBase64/index.d.ts +0 -15
  188. package/src/framework/components/field/FieldImageBase64/index.jsx +0 -22
  189. package/src/framework/components/field/FieldInput.jsx +0 -13
  190. package/src/framework/components/field/FieldOrgTree/index.tsx +0 -45
  191. package/src/framework/components/field/FieldPassword.jsx +0 -11
  192. package/src/framework/components/field/FieldProps.ts +0 -19
  193. package/src/framework/components/field/FieldRemoteTreeCascader.jsx +0 -75
  194. package/src/framework/components/field/FieldRemoteTreeCheckable.jsx +0 -81
  195. package/src/framework/components/field/FieldRemoteTreeMultipleSelect.jsx +0 -100
  196. package/src/framework/components/field/FieldRemoteTreeSelect.jsx +0 -82
  197. package/src/framework/components/field/FieldSelectPosition/index.tsx +0 -85
  198. package/src/framework/components/field/FieldTree.jsx +0 -45
  199. package/src/framework/components/field/dict/index.tsx +0 -110
  200. package/src/framework/components/field/flat-multiple-select/index.d.ts +0 -4
  201. package/src/framework/components/field/flat-multiple-select/index.jsx +0 -116
  202. package/src/framework/components/field/flat-multiple-select/index.less +0 -12
  203. package/src/framework/components/field/flat-select/index.d.ts +0 -4
  204. package/src/framework/components/field/flat-select/index.jsx +0 -107
  205. package/src/framework/components/field/flat-select/index.less +0 -12
  206. package/src/framework/components/field/index.js +0 -33
  207. package/src/framework/components/field/input-number-percent/index.d.ts +0 -11
  208. package/src/framework/components/field/input-number-percent/index.jsx +0 -28
  209. package/src/framework/components/field/select/FieldSelect/index.d.ts +0 -39
  210. package/src/framework/components/field/select/FieldSelect/index.jsx +0 -156
  211. package/src/framework/components/field/select/FieldTableSelect/index.jsx +0 -155
  212. package/src/framework/components/field/select/index.jsx +0 -2
  213. package/src/framework/components/field/switch-y-n/index.d.ts +0 -11
  214. package/src/framework/components/field/switch-y-n/index.jsx +0 -31
  215. package/src/framework/components/field/text/index.tsx +0 -7
  216. package/src/framework/components/field/time/DatePickerString.tsx +0 -37
  217. package/src/framework/components/field/time/DateTimePickerString.tsx +0 -42
  218. package/src/framework/components/field/time/FieldDateRange.d.ts +0 -9
  219. package/src/framework/components/field/time/FieldDateRange.jsx +0 -49
  220. package/src/framework/components/field/time/HHmmPickerString.tsx +0 -42
  221. package/src/framework/components/field/time/MonthPickerString.tsx +0 -45
  222. package/src/framework/components/field/time/TimePickerTool.ts +0 -14
  223. package/src/framework/components/field/time/YearPickerString.tsx +0 -41
  224. package/src/framework/components/field/time/YearQuarterString.tsx +0 -38
  225. package/src/framework/components/field/time/index.tsx +0 -7
  226. package/src/framework/components/field/upload/FieldUploadCropImage/index.d.ts +0 -22
  227. package/src/framework/components/field/upload/FieldUploadCropImage/index.jsx +0 -11
  228. package/src/framework/components/field/upload/FieldUploadImage.d.ts +0 -7
  229. package/src/framework/components/field/upload/FieldUploadImage.jsx +0 -16
  230. package/src/framework/components/field/upload/index.jsx +0 -3
  231. package/src/framework/components/system.jsx +0 -29
  232. package/src/framework/components/view/ViewBoolean.jsx +0 -15
  233. package/src/framework/components/view/ViewBooleanEnableDisable.jsx +0 -16
  234. package/src/framework/components/view/ViewText.jsx +0 -9
  235. package/src/framework/index.js +0 -3
  236. package/src/framework/system/dict.js +0 -88
  237. package/src/framework/system/formRegistry.js +0 -58
  238. package/src/framework/system/http.jsx +0 -290
  239. package/src/framework/system/index.js +0 -13
  240. package/src/framework/system/page.js +0 -109
  241. package/src/framework/system/permission.js +0 -44
  242. package/src/framework/system/sys.js +0 -60
  243. package/src/framework/system/theme.js +0 -17
  244. package/src/framework/utils/arr.js +0 -118
  245. package/src/framework/utils/browser.js +0 -24
  246. package/src/framework/utils/color.js +0 -269
  247. package/src/framework/utils/debounce.js +0 -33
  248. package/src/framework/utils/dom.js +0 -16
  249. package/src/framework/utils/eventBus.js +0 -70
  250. package/src/framework/utils/html.js +0 -13
  251. package/src/framework/utils/index.js +0 -17
  252. package/src/framework/utils/obj.js +0 -72
  253. package/src/framework/utils/storage.js +0 -37
  254. package/src/framework/utils/str.js +0 -297
  255. package/src/framework/utils/tree.js +0 -175
  256. package/src/framework/utils/uid.js +0 -76
  257. package/src/framework/utils/url.js +0 -84
  258. package/src/framework/utils/validate.js +0 -9
  259. package/src/pages/api/accessLog/index.jsx +0 -108
  260. package/src/pages/api/accountResource/index.jsx +0 -149
  261. package/src/pages/api/index.jsx +0 -163
  262. package/src/pages/api/resource.jsx +0 -18
  263. package/src/pages/flowable/instance/view.jsx +0 -13
  264. package/src/pages/flowable/monitor.jsx +0 -106
  265. package/src/pages/flowable/test/form.jsx +0 -31
  266. package/src/pages/job/logList.jsx +0 -100
  267. package/src/pages/job/status.jsx +0 -84
  268. /package/src/framework/components/{ButtonList.d.ts → system/ButtonList.d.ts} +0 -0
  269. /package/src/framework/{components/EditTable/index.less → field-components/FieldTable.less} +0 -0
  270. /package/src/framework/{components/view → view-components}/ViewPassword.jsx +0 -0
  271. /package/src/{index.js → index.ts} +0 -0
  272. /package/src/{components/flow → pages/flowable}/design/contextPad.js +0 -0
@@ -1,44 +0,0 @@
1
- /**
2
- * 控制按钮是否显示
3
- */
4
- import {SysUtil} from "./sys";
5
- import {ArrUtil} from "../utils";
6
-
7
-
8
- export const PermUtil = {
9
-
10
- /**
11
- * 是否拥有权限
12
- * @param perm 权限码
13
- */
14
- hasPermission(perm) {
15
- if (perm === null || perm === '') {
16
- return false;
17
- }
18
-
19
- const info = SysUtil.getLoginInfo();
20
- const { permissions } = info;
21
- if(permissions == null || permissions.length === 0){
22
- return false
23
- }
24
-
25
- if (ArrUtil.contains(permissions,"*")) {
26
- return true;
27
- }
28
-
29
- return permissions.indexOf(perm) > -1;
30
- },
31
-
32
- /**
33
- * 是否授权, 同 hasPermission
34
- * @param p
35
- * @returns {boolean}
36
- */
37
- isPermitted(p){
38
- return PermUtil.hasPermission(p)
39
- },
40
- notPermitted(p){
41
- !PermUtil.isPermitted(p)
42
- }
43
-
44
- }
@@ -1,60 +0,0 @@
1
- import {StorageUtil, UrlUtil} from "../utils";
2
-
3
- const SITE_INFO_KEY = "siteInfo"
4
- const LOGIN_INFO_KEY = "loginInfo"
5
- const DICT_INFO_KEY = "dictInfo"
6
- export const SysUtil = {
7
-
8
-
9
-
10
- /**
11
- * 服务器端的地址, 以 /结尾
12
- * @returns {string}
13
- */
14
- getServerUrl() {
15
- return "/"
16
- },
17
-
18
- /**
19
- * 将服务url加载最前
20
- * @param url
21
- * @returns {*}
22
- */
23
- wrapServerUrl(url) {
24
- const serverUrl = SysUtil.getServerUrl()
25
- return UrlUtil.join(serverUrl, url)
26
- },
27
-
28
-
29
- getHeaders() {
30
- const headers = {}
31
- return headers;
32
- },
33
-
34
- setSiteInfo(data) {
35
- return StorageUtil.set(SITE_INFO_KEY, data)
36
- },
37
-
38
- getSiteInfo() {
39
- return StorageUtil.get(SITE_INFO_KEY) || {}
40
- },
41
-
42
- setLoginInfo(data) {
43
- return StorageUtil.set(LOGIN_INFO_KEY, data)
44
- },
45
-
46
- getLoginInfo() {
47
- return StorageUtil.get(LOGIN_INFO_KEY) || {}
48
- },
49
-
50
-
51
- setDictInfo(data) {
52
- return StorageUtil.set(DICT_INFO_KEY, data)
53
- },
54
-
55
- getDictInfo() {
56
- return StorageUtil.get(DICT_INFO_KEY)
57
- }
58
- }
59
-
60
-
@@ -1,17 +0,0 @@
1
- export const theme = {
2
- "primary-color": "#1961AC",
3
- "success-color": "#52c41a",
4
- "warning-color": "#faad14",
5
- "error-color": "#ff4d4f",
6
- "background-color":"#f5f5f5",
7
-
8
-
9
- "primary-color-hover":"#4990CD",
10
- "primary-color-click":"#124B93"
11
- }
12
-
13
-
14
-
15
-
16
-
17
-
@@ -1,118 +0,0 @@
1
- export const ArrUtil = {
2
-
3
- contains(arr, item) {
4
- return arr.indexOf(item) !== -1;
5
- },
6
- containsAny(arr, ...items) {
7
- for (let item of items) {
8
- if (this.contains(item)) {
9
- return true
10
- }
11
- }
12
- return false;
13
- },
14
-
15
- add(arr, item) {
16
- arr.push(item)
17
- },
18
-
19
- addAt(arr, index, item) {
20
- arr.splice(index, 0, item);
21
- },
22
-
23
- /**
24
- * 将一个数组追加到尾
25
- * @param index
26
- * @param item
27
- */
28
- addAll(arr, items) {
29
- for (let i = 0; i < items.length; i++) {
30
- arr.push(items[i])
31
- }
32
- },
33
-
34
- removeAt(arr, index) {
35
- arr.splice(index, 1)
36
- },
37
-
38
- remove(arr, item) {
39
- const index = arr.indexOf(item);
40
- if (index !== -1) {
41
- this.removeAt(arr, index)
42
- }
43
- },
44
-
45
- /**
46
- * 清空
47
- */
48
- clear(arr) {
49
- arr.length = 0
50
- },
51
-
52
- /**
53
- * 截取数组
54
- * @param fromIndex low endpoint (inclusive) of the subList toIndex
55
- * @param toIndex high endpoint (exclusive) of the subList
56
- */
57
- sub(arr, fromIndex, toIndex) {
58
- return arr.slice(fromIndex, toIndex);
59
- },
60
-
61
- swap(arr, item1, item2) {
62
- const index1 = arr.indexOf(item1);
63
- const index2 = arr.indexOf(item2);
64
-
65
- arr[index1] = item2;
66
- arr[index2] = item1;
67
- },
68
-
69
- insert(arr, index, item) {
70
- arr.splice(index, 0, item);
71
- },
72
-
73
- pushIfNotExist(arr, item) {
74
- const index = arr.indexOf(item);
75
- if (index == -1) {
76
- arr.push(item);
77
- }
78
- },
79
-
80
- pushAll(arr, newArr) {
81
- for (let i = 0; i < newArr.length; i++) {
82
- arr.push(newArr[i]);
83
- }
84
- },
85
-
86
- /**
87
- * 获取对象数组中某一属性值最大的对象
88
- * @param arr
89
- */
90
- maxBy(arr, key) {
91
- if (arr == null || arr.length === 0) {
92
- return undefined;
93
- }
94
-
95
- let maxElement;
96
- let maxValue = -Infinity;
97
-
98
- for (const element of arr) {
99
- const value = element[key];
100
- if (value > maxValue) {
101
- maxValue = value;
102
- maxElement = element;
103
- }
104
- }
105
-
106
- return maxElement;
107
- },
108
-
109
- /**
110
- * 数组去重
111
- * @param arr
112
- * @returns {any[]}
113
- */
114
- unique(arr) {
115
- return [...new Set(arr)]
116
- }
117
-
118
- }
@@ -1,24 +0,0 @@
1
- export function isMobileDevice() {
2
- const userAgent = navigator.userAgent || navigator.vendor || window.opera;
3
-
4
- // Windows Phone must come first because its UA also contains "Android"
5
- if (/windows phone/i.test(userAgent)) {
6
- return true;
7
- }
8
-
9
- // Android devices
10
- if (/android/i.test(userAgent)) {
11
- return true;
12
- }
13
-
14
- // iOS devices
15
- if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
16
- return true;
17
- }
18
- return false;
19
- }
20
-
21
- export function getWebsocketBaseUrl() {
22
- const protocol = location.protocol === 'http:' ? 'ws:' : 'wss:'
23
- return protocol + "//" + location.host
24
- }
@@ -1,269 +0,0 @@
1
- /**
2
- * forked form https://github.com/quasarframework/quasar
3
- */
4
-
5
-
6
- const reRGBA = /^rgb(a)?\((\d{1,3}),(\d{1,3}),(\d{1,3}),?([01]?\.?\d*?)?\)$/
7
-
8
- export function rgbToHex ({ r, g, b, a }) {
9
- const alpha = a !== void 0
10
-
11
- r = Math.round(r)
12
- g = Math.round(g)
13
- b = Math.round(b)
14
-
15
- if (
16
- r > 255
17
- || g > 255
18
- || b > 255
19
- || (alpha && a > 100)
20
- ) {
21
- throw new TypeError('Expected 3 numbers below 256 (and optionally one below 100)')
22
- }
23
-
24
- a = alpha
25
- ? (Math.round(255 * a / 100) | 1 << 8).toString(16).slice(1)
26
- : ''
27
-
28
- return '#' + ((b | g << 8 | r << 16) | 1 << 24).toString(16).slice(1) + a
29
- }
30
-
31
- export function rgbToString ({ r, g, b, a }) {
32
- return `rgb${ a !== void 0 ? 'a' : '' }(${ r },${ g },${ b }${ a !== void 0 ? ',' + (a / 100) : '' })`
33
- }
34
-
35
- export function hexToRgb (hex) {
36
- if (typeof hex !== 'string') {
37
- throw new TypeError('Expected a string')
38
- }
39
-
40
- hex = hex.replace(/^#/, '')
41
-
42
- if (hex.length === 3) {
43
- hex = hex[ 0 ] + hex[ 0 ] + hex[ 1 ] + hex[ 1 ] + hex[ 2 ] + hex[ 2 ]
44
- }
45
- else if (hex.length === 4) {
46
- hex = hex[ 0 ] + hex[ 0 ] + hex[ 1 ] + hex[ 1 ] + hex[ 2 ] + hex[ 2 ] + hex[ 3 ] + hex[ 3 ]
47
- }
48
-
49
- const num = parseInt(hex, 16)
50
-
51
- return hex.length > 6
52
- ? { r: num >> 24 & 255, g: num >> 16 & 255, b: num >> 8 & 255, a: Math.round((num & 255) / 2.55) }
53
- : { r: num >> 16, g: num >> 8 & 255, b: num & 255 }
54
- }
55
-
56
- export function hsvToRgb ({ h, s, v, a }) {
57
- let r, g, b
58
- s = s / 100
59
- v = v / 100
60
-
61
- h = h / 360
62
- const
63
- i = Math.floor(h * 6),
64
- f = h * 6 - i,
65
- p = v * (1 - s),
66
- q = v * (1 - f * s),
67
- t = v * (1 - (1 - f) * s)
68
-
69
- switch (i % 6) {
70
- case 0:
71
- r = v
72
- g = t
73
- b = p
74
- break
75
- case 1:
76
- r = q
77
- g = v
78
- b = p
79
- break
80
- case 2:
81
- r = p
82
- g = v
83
- b = t
84
- break
85
- case 3:
86
- r = p
87
- g = q
88
- b = v
89
- break
90
- case 4:
91
- r = t
92
- g = p
93
- b = v
94
- break
95
- case 5:
96
- r = v
97
- g = p
98
- b = q
99
- break
100
- }
101
-
102
- return {
103
- r: Math.round(r * 255),
104
- g: Math.round(g * 255),
105
- b: Math.round(b * 255),
106
- a
107
- }
108
- }
109
-
110
- export function rgbToHsv ({ r, g, b, a }) {
111
- const
112
- max = Math.max(r, g, b),
113
- min = Math.min(r, g, b),
114
- d = max - min,
115
- s = (max === 0 ? 0 : d / max),
116
- v = max / 255
117
- let h
118
-
119
- switch (max) {
120
- case min:
121
- h = 0
122
- break
123
- case r:
124
- h = (g - b) + d * (g < b ? 6 : 0)
125
- h /= 6 * d
126
- break
127
- case g:
128
- h = (b - r) + d * 2
129
- h /= 6 * d
130
- break
131
- case b:
132
- h = (r - g) + d * 4
133
- h /= 6 * d
134
- break
135
- }
136
-
137
- return {
138
- h: Math.round(h * 360),
139
- s: Math.round(s * 100),
140
- v: Math.round(v * 100),
141
- a
142
- }
143
- }
144
-
145
- export function textToRgb (str) {
146
- if (typeof str !== 'string') {
147
- throw new TypeError('Expected a string')
148
- }
149
-
150
- const color = str.replace(/ /g, '')
151
-
152
- const m = reRGBA.exec(color)
153
-
154
- if (m === null) {
155
- return hexToRgb(color)
156
- }
157
-
158
- const rgb = {
159
- r: Math.min(255, parseInt(m[ 2 ], 10)),
160
- g: Math.min(255, parseInt(m[ 3 ], 10)),
161
- b: Math.min(255, parseInt(m[ 4 ], 10))
162
- }
163
-
164
- if (m[ 1 ]) {
165
- const alpha = parseFloat(m[ 5 ])
166
- rgb.a = Math.min(1, isNaN(alpha) === true ? 1 : alpha) * 100
167
- }
168
-
169
- return rgb
170
- }
171
-
172
- /* works as darken if percent < 0 */
173
- export function lighten (color, percent) {
174
- if (typeof color !== 'string') {
175
- throw new TypeError('Expected a string as color')
176
- }
177
- if (typeof percent !== 'number') {
178
- throw new TypeError('Expected a numeric percent')
179
- }
180
-
181
- const rgb = textToRgb(color),
182
- t = percent < 0 ? 0 : 255,
183
- p = Math.abs(percent) / 100,
184
- R = rgb.r,
185
- G = rgb.g,
186
- B = rgb.b
187
-
188
- return '#' + (
189
- 0x1000000 + (Math.round((t - R) * p) + R) * 0x10000
190
- + (Math.round((t - G) * p) + G) * 0x100
191
- + (Math.round((t - B) * p) + B)
192
- ).toString(16).slice(1)
193
- }
194
-
195
- export function luminosity (color) {
196
- if (typeof color !== 'string' && (!color || color.r === void 0)) {
197
- throw new TypeError('Expected a string or a {r, g, b} object as color')
198
- }
199
-
200
- const
201
- rgb = typeof color === 'string' ? textToRgb(color) : color,
202
- r = rgb.r / 255,
203
- g = rgb.g / 255,
204
- b = rgb.b / 255,
205
- R = r <= 0.03928 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4),
206
- G = g <= 0.03928 ? g / 12.92 : Math.pow((g + 0.055) / 1.055, 2.4),
207
- B = b <= 0.03928 ? b / 12.92 : Math.pow((b + 0.055) / 1.055, 2.4)
208
- return 0.2126 * R + 0.7152 * G + 0.0722 * B
209
- }
210
-
211
- export function brightness (color) {
212
- if (typeof color !== 'string' && (!color || color.r === void 0)) {
213
- throw new TypeError('Expected a string or a {r, g, b} object as color')
214
- }
215
-
216
- const rgb = typeof color === 'string'
217
- ? textToRgb(color)
218
- : color
219
-
220
- return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000
221
- }
222
-
223
- export function blend (fgColor, bgColor) {
224
- if (typeof fgColor !== 'string' && (!fgColor || fgColor.r === void 0)) {
225
- throw new TypeError('Expected a string or a {r, g, b[, a]} object as fgColor')
226
- }
227
-
228
- if (typeof bgColor !== 'string' && (!bgColor || bgColor.r === void 0)) {
229
- throw new TypeError('Expected a string or a {r, g, b[, a]} object as bgColor')
230
- }
231
-
232
- const
233
- rgb1 = typeof fgColor === 'string' ? textToRgb(fgColor) : fgColor,
234
- r1 = rgb1.r / 255,
235
- g1 = rgb1.g / 255,
236
- b1 = rgb1.b / 255,
237
- a1 = rgb1.a !== void 0 ? rgb1.a / 100 : 1,
238
- rgb2 = typeof bgColor === 'string' ? textToRgb(bgColor) : bgColor,
239
- r2 = rgb2.r / 255,
240
- g2 = rgb2.g / 255,
241
- b2 = rgb2.b / 255,
242
- a2 = rgb2.a !== void 0 ? rgb2.a / 100 : 1,
243
- a = a1 + a2 * (1 - a1),
244
- r = Math.round(((r1 * a1 + r2 * a2 * (1 - a1)) / a) * 255),
245
- g = Math.round(((g1 * a1 + g2 * a2 * (1 - a1)) / a) * 255),
246
- b = Math.round(((b1 * a1 + b2 * a2 * (1 - a1)) / a) * 255)
247
-
248
- const ret = { r, g, b, a: Math.round(a * 100) }
249
- return typeof fgColor === 'string'
250
- ? rgbToHex(ret)
251
- : ret
252
- }
253
-
254
- export function changeAlpha (color, offset) {
255
- if (typeof color !== 'string') {
256
- throw new TypeError('Expected a string as color')
257
- }
258
-
259
- if (offset === void 0 || offset < -1 || offset > 1) {
260
- throw new TypeError('Expected offset to be between -1 and 1')
261
- }
262
-
263
- const { r, g, b, a } = textToRgb(color)
264
- const alpha = a !== void 0 ? a / 100 : 0
265
-
266
- return rgbToHex({
267
- r, g, b, a: Math.round(Math.min(1, Math.max(0, alpha + offset)) * 100)
268
- })
269
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * 防抖
3
- *
4
- * forked form https://github.com/quasarframework/quasar
5
- */
6
- export function debounce(fn, wait = 250, immediate) {
7
- let timer = null
8
-
9
- function debounced(/* ...args */) {
10
- const args = arguments
11
-
12
- const later = () => {
13
- timer = null
14
- if (immediate !== true) {
15
- fn.apply(this, args)
16
- }
17
- }
18
-
19
- if (timer !== null) {
20
- clearTimeout(timer)
21
- } else if (immediate === true) {
22
- fn.apply(this, args)
23
- }
24
-
25
- timer = setTimeout(later, wait)
26
- }
27
-
28
- debounced.cancel = () => {
29
- timer !== null && clearTimeout(timer)
30
- }
31
-
32
- return debounced
33
- }
@@ -1,16 +0,0 @@
1
- export function offset (el) {
2
- if (el === window) {
3
- return { top: 0, left: 0 }
4
- }
5
- const { top, left } = el.getBoundingClientRect()
6
- return { top, left }
7
- }
8
- export function height (el) {
9
- return el === window
10
- ? window.innerHeight
11
- : el.getBoundingClientRect().height
12
- }export function width (el) {
13
- return el === window
14
- ? window.innerWidth
15
- : el.getBoundingClientRect().width
16
- }
@@ -1,70 +0,0 @@
1
- /**
2
- * 事件总线
3
- * forked form https://github.com/scottcorgan/tiny-emitter
4
- */
5
-
6
- export class EventBus {
7
- constructor () {
8
- this.__stack = {}
9
- }
10
-
11
- on (name, callback, ctx) {
12
- (this.__stack[ name ] || (this.__stack[ name ] = [])).push({
13
- fn: callback,
14
- ctx
15
- })
16
-
17
- return this // chainable
18
- }
19
-
20
- once (name, callback, ctx) {
21
- const listener = (...args) => {
22
- this.off(name, listener)
23
- callback.apply(ctx, args)
24
- }
25
-
26
- listener.__callback = callback
27
- return this.on(name, listener, ctx) // chainable
28
- }
29
-
30
- emit (name) {
31
- const list = this.__stack[ name ]
32
-
33
- if (list !== void 0) {
34
- const params = [].slice.call(arguments, 1)
35
- list.forEach(entry => {
36
- entry.fn.apply(entry.ctx, params)
37
- })
38
- }
39
-
40
- return this // chainable
41
- }
42
-
43
- off (name, callback) {
44
- const list = this.__stack[ name ]
45
-
46
- if (list === void 0) {
47
- return this // chainable
48
- }
49
-
50
- if (callback === void 0) {
51
- delete this.__stack[ name ]
52
- return this // chainable
53
- }
54
-
55
- const liveEvents = list.filter(
56
- entry => entry.fn !== callback && entry.fn.__callback !== callback
57
- )
58
-
59
- if (liveEvents.length !== 0) {
60
- this.__stack[ name ] = liveEvents
61
- }
62
- else {
63
- delete this.__stack[ name ]
64
- }
65
-
66
- return this // chainable
67
- }
68
- }
69
-
70
- export const eventBus = new EventBus()
@@ -1,13 +0,0 @@
1
-
2
- export function getIframeCommonProps() {
3
-
4
- return {
5
- width: '100%',
6
- frameBorder: 0,
7
- marginHeight: 0,
8
- marginWidth: 0
9
- }
10
- }
11
-
12
-
13
-
@@ -1,17 +0,0 @@
1
- export * from "./date";
2
- export * from "./arr";
3
- export * from "./html";
4
- export * from "./url"
5
- export * from "./str"
6
- export * from "./eventBus";
7
- export * from "./color"
8
- export * from "./debounce";
9
- export * from "./dom"
10
- export * from "./uid";
11
- export * from './validate'
12
-
13
- export * from "./str"
14
- export * from "./tree";
15
- export * from './storage'
16
- export * from './browser'
17
- export * from './obj'