@gct-paas/core 0.1.4-dev.11 → 0.1.4-dev.13

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 (142) hide show
  1. package/dist/index.esm.min.js +4522 -0
  2. package/es/constants/core.mjs +5 -4
  3. package/es/constants/default-date-type/default-date-type.mjs +73 -21
  4. package/es/constants/editor-register/editor-register.mjs +17 -5
  5. package/es/constants/expression-type/BuiltOperators.mjs +152 -147
  6. package/es/constants/expression-type/FunctionKeys.mjs +75 -79
  7. package/es/constants/expression-type/editor.mjs +10 -3
  8. package/es/constants/expression-type/function.mjs +602 -613
  9. package/es/constants/expression-type/index.mjs +111 -113
  10. package/es/constants/expression-type/modeCfg.mjs +256 -263
  11. package/es/constants/expression-type/variable.mjs +43 -39
  12. package/es/constants/form-container-type/form-container-type.mjs +17 -5
  13. package/es/constants/index.d.ts +1 -0
  14. package/es/constants/index.mjs +31 -10
  15. package/es/constants/page-designer/model.mjs +15 -5
  16. package/es/constants/page-designer/regex.d.ts +2 -0
  17. package/es/constants/page-designer/regex.mjs +5 -0
  18. package/es/create-app-vue.mjs +15 -9
  19. package/es/enums/app-designer/index.d.ts +19 -0
  20. package/es/enums/app-designer/index.mjs +131 -63
  21. package/es/enums/appEnum.mjs +681 -360
  22. package/es/enums/appStateEnum.mjs +17 -10
  23. package/es/enums/authActionEnum.mjs +63 -51
  24. package/es/enums/breakpointEnum.mjs +27 -26
  25. package/es/enums/cacheEnum.mjs +22 -21
  26. package/es/enums/designEnum.mjs +110 -71
  27. package/es/enums/developer-center/integration.mjs +7 -6
  28. package/es/enums/exceptionEnum.mjs +21 -17
  29. package/es/enums/expressionEnum.d.ts +1 -1
  30. package/es/enums/expressionEnum.mjs +81 -74
  31. package/es/enums/globalEnum.mjs +59 -36
  32. package/es/enums/httpEnum.mjs +71 -61
  33. package/es/enums/index.mjs +44 -14
  34. package/es/enums/menuEnum.mjs +42 -38
  35. package/es/enums/page-designer/designer.mjs +403 -407
  36. package/es/enums/page-designer/index.d.ts +1 -0
  37. package/es/enums/page-designer/index.mjs +5 -0
  38. package/es/enums/page-designer/layout.d.ts +12 -0
  39. package/es/enums/page-designer/layout.mjs +17 -0
  40. package/es/enums/page-designer/panel.mjs +341 -213
  41. package/es/enums/page-designer/toolkit.mjs +13 -12
  42. package/es/enums/page-designer/widget.mjs +425 -338
  43. package/es/enums/pageEnum.mjs +14 -13
  44. package/es/enums/plugin-enum.mjs +23 -7
  45. package/es/enums/processEnum.mjs +95 -60
  46. package/es/enums/roleEnum.mjs +7 -6
  47. package/es/enums/sizeEnum.d.ts +18 -0
  48. package/es/enums/sizeEnum.mjs +28 -8
  49. package/es/global/gct/gct.mjs +84 -96
  50. package/es/global/index.mjs +1 -0
  51. package/es/hooks/index.mjs +4 -0
  52. package/es/hooks/use-app-inst/use-app-inst.mjs +11 -5
  53. package/es/hooks/use-modal/use-modal.mjs +16 -10
  54. package/es/hooks/use-sub-app-utils/use-sub-app-utils.mjs +43 -23
  55. package/es/hooks/useCopyToClipboard.mjs +50 -50
  56. package/es/index.mjs +125 -114
  57. package/es/interface/i-pinia-state/i-global-state.d.ts +0 -11
  58. package/es/locale/index.mjs +50 -57
  59. package/es/modules/env-manager/env-manager.const.mjs +16 -8
  60. package/es/modules/env-manager/env-manager.d.ts +2 -0
  61. package/es/modules/env-manager/env-manager.interface.d.ts +2 -0
  62. package/es/modules/env-manager/env-manager.interface.mjs +14 -7
  63. package/es/modules/env-manager/env-manager.mjs +108 -107
  64. package/es/modules/error-handler/error-handler.const.mjs +11 -16
  65. package/es/modules/error-handler/error-strategy.mjs +199 -175
  66. package/es/modules/error-handler/index.mjs +120 -106
  67. package/es/modules/mqtt/constants/mqtt.const.mjs +21 -24
  68. package/es/modules/mqtt/enums/mqtt-status.enum.mjs +23 -9
  69. package/es/modules/mqtt/index.mjs +4 -0
  70. package/es/modules/mqtt/mqtt-client.mjs +228 -261
  71. package/es/modules/mqtt/mqtt-manager.mjs +117 -77
  72. package/es/modules/platform-config/constants/index.mjs +4 -0
  73. package/es/modules/platform-config/constants/login.const.mjs +48 -45
  74. package/es/modules/platform-config/constants/org.const.mjs +57 -52
  75. package/es/modules/platform-config/constants/theme.const.mjs +11 -4
  76. package/es/modules/platform-config/constants/watermark.const.mjs +17 -12
  77. package/es/modules/platform-config/enums/deploy.enum.mjs +13 -6
  78. package/es/modules/platform-config/enums/login.enum.mjs +29 -15
  79. package/es/modules/platform-config/enums/platform.enum.mjs +16 -13
  80. package/es/modules/platform-config/index.mjs +9 -0
  81. package/es/modules/platform-config/store.mjs +68 -79
  82. package/es/modules/platform-config/useBasicSetting.mjs +47 -35
  83. package/es/modules/platform-config/useDeploySetting.mjs +29 -21
  84. package/es/modules/platform-config/useLoginSetting.mjs +151 -173
  85. package/es/modules/platform-config/useOrgSetting.mjs +63 -62
  86. package/es/modules/platform-config/useProjectSetting.mjs +14 -6
  87. package/es/modules/platform-config/useSecuritySetting.mjs +68 -56
  88. package/es/modules/platform-config/useThemeSetting.mjs +78 -59
  89. package/es/modules/platform-config/useWatermarkSetting.mjs +37 -23
  90. package/es/modules/user-stores/index.mjs +3 -0
  91. package/es/modules/user-stores/store/permission.store.mjs +27 -36
  92. package/es/modules/user-stores/store/tenant.store.mjs +20 -22
  93. package/es/modules/user-stores/store/user.store.mjs +94 -117
  94. package/es/router/index.mjs +25 -28
  95. package/es/setup-app.mjs +23 -39
  96. package/es/state/global-pinia-state/global-pinia-state.d.ts +0 -6
  97. package/es/state/global-pinia-state/global-pinia-state.mjs +43 -71
  98. package/es/state/index.mjs +1 -0
  99. package/es/store/global-store.mjs +50 -72
  100. package/es/store/index.mjs +25 -19
  101. package/es/types/index.d.ts +7 -0
  102. package/es/utils/axios/interceptors.mjs +21 -17
  103. package/es/utils/cache-adapter/cache-adapter.mjs +61 -56
  104. package/es/utils/css-loader/css-loader.d.ts +36 -0
  105. package/es/utils/css-loader/css-loader.mjs +82 -0
  106. package/es/utils/design/design.mjs +18 -12
  107. package/es/utils/deviceFingerprint.mjs +77 -63
  108. package/es/utils/dictionary/dictionary.mjs +142 -145
  109. package/es/utils/file/base64Conver.mjs +35 -30
  110. package/es/utils/file/download.mjs +94 -98
  111. package/es/utils/file/parser.d.ts +3 -0
  112. package/es/utils/file/parser.mjs +29 -0
  113. package/es/utils/i18n/index.mjs +14 -3
  114. package/es/utils/index.d.ts +3 -1
  115. package/es/utils/index.mjs +32 -0
  116. package/es/utils/is-sort-filed/is-sort-filed.mjs +42 -37
  117. package/es/utils/linked-list/linked-list.mjs +115 -118
  118. package/es/utils/linked-node/linked-node.mjs +41 -31
  119. package/es/utils/lowcode/utils.mjs +13 -18
  120. package/es/utils/lowcode/validate.mjs +20 -26
  121. package/es/utils/mitt/mitt.mjs +4 -4
  122. package/es/utils/model-loader/model-loader.mjs +280 -325
  123. package/es/utils/namespace/namespace.mjs +178 -164
  124. package/es/utils/openUtil/index.mjs +2 -0
  125. package/es/utils/openUtil/modal/modal.mjs +72 -79
  126. package/es/utils/openUtil/overlay-container/overlay-container.mjs +144 -138
  127. package/es/utils/permission.mjs +33 -37
  128. package/es/utils/plugin-static-resource/plugin-static-resource.mjs +46 -42
  129. package/es/utils/style/index.mjs +94 -138
  130. package/es/utils/tools/tools.mjs +86 -54
  131. package/es/utils/treeHelper/treeHelper.mjs +205 -233
  132. package/es/utils/uploader/uploader.mjs +81 -115
  133. package/es/utils/useUUid.mjs +79 -87
  134. package/es/utils/util.mjs +55 -35
  135. package/es/utils/uuid/uuid.d.ts +2 -0
  136. package/es/utils/uuid/uuid.mjs +33 -43
  137. package/es/utils/validate.mjs +15 -19
  138. package/es/utils/value-helper/value-helper.mjs +113 -98
  139. package/package.json +9 -18
  140. package/dist/index.esm.min.mjs +0 -18322
  141. package/dist/index.min.cjs +0 -393
  142. package/dist/index.system.min.js +0 -393
@@ -1,141 +1,97 @@
1
- const calcStyle = (data, ignoringStyle = []) => {
2
- const style = {};
3
- const padding = data.padding;
4
- if (padding) {
5
- if (padding.top != null && padding.top != "" && !ignoringStyle.includes("paddingTop"))
6
- style["padding-top"] = padding.top;
7
- if (padding.right != null && padding.right != "" && !ignoringStyle.includes("paddingRight"))
8
- style["padding-right"] = padding.right;
9
- if (padding.bottom != null && padding.bottom != "" && !ignoringStyle.includes("paddingBottom"))
10
- style["padding-bottom"] = padding.bottom;
11
- if (padding.left != null && padding.left != "" && !ignoringStyle.includes("paddingLeft"))
12
- style["padding-left"] = padding.left;
13
- }
14
- const margin = data.margin;
15
- if (margin) {
16
- if (margin.top != null && margin.top != "" && !ignoringStyle.includes("marginTop"))
17
- style["margin-top"] = margin.top;
18
- if (margin.right != null && margin.right != "" && !ignoringStyle.includes("marginRight"))
19
- style["margin-right"] = margin.right;
20
- if (margin.bottom != null && margin.bottom != "" && !ignoringStyle.includes("marginBottom"))
21
- style["margin-bottom"] = margin.bottom;
22
- if (margin.left != null && margin.left != "" && !ignoringStyle.includes("marginLeft"))
23
- style["margin-left"] = margin.left;
24
- }
25
- if (data.background != null && data.background != "" && !ignoringStyle.includes("backgroundColor")) {
26
- style["background-color"] = data.background;
27
- }
28
- if (data.width != null && data.width != "" && !ignoringStyle.includes("width")) {
29
- style.width = data.width;
30
- }
31
- if (data.height != null && data.height != "" && !ignoringStyle.includes("height")) {
32
- style.height = data.height;
33
- style.overflowX = "hidden";
34
- style.overflowY = "auto";
35
- }
36
- const position = data.position;
37
- if (position) {
38
- if (position.position != null && position.position != "" && !ignoringStyle.includes("zIndex")) {
39
- style.position = position.position;
40
- style["z-index"] = 1;
41
- }
42
- if (position.top != null && position.top != "" && !ignoringStyle.includes("top"))
43
- style.top = `${position.top}px`;
44
- if (position.right != null && position.right != "" && !ignoringStyle.includes("right"))
45
- style.right = `${position.right}px`;
46
- if (position.bottom != null && position.bottom != "" && !ignoringStyle.includes("bottom"))
47
- style.bottom = `${position.bottom}px`;
48
- if (position.left != null && position.left != "" && !ignoringStyle.includes("left"))
49
- style.left = `${position.left}px`;
50
- }
51
- const border = data.border;
52
- if (border) {
53
- if (border.topLeftRadius != null && border.topLeftRadius != "" && !ignoringStyle.includes("borderTopLeftRadius")) {
54
- style["border-top-left-radius"] = border.topLeftRadius;
55
- }
56
- if (border.topRightRadius != null && border.topRightRadius != "" && !ignoringStyle.includes("borderTopRightRadius")) {
57
- style["border-top-right-radius"] = border.topRightRadius;
58
- }
59
- if (border.bottomLeftRadius != null && border.bottomLeftRadius != "" && !ignoringStyle.includes("borderBottomLeftRadius")) {
60
- style["border-bottom-left-radius"] = border.bottomLeftRadius;
61
- }
62
- if (border.bottomRightRadius != null && border.bottomRightRadius != "" && !ignoringStyle.includes("borderBottomRightRadius")) {
63
- style["border-bottom-right-radius"] = border.bottomRightRadius;
64
- }
65
- if (border.top) {
66
- if (border.top.color != null && border.top.color != "" && !ignoringStyle.includes("borderTopColor")) {
67
- style["border-top-color"] = border.top.color;
68
- }
69
- if (border.top.width != null && border.top.width != "" && !ignoringStyle.includes("borderTopWidth")) {
70
- style["border-top-width"] = border.top.width;
71
- }
72
- if (border.top.style && !ignoringStyle.includes("borderTopStyle")) {
73
- style["border-top-style"] = border.top.style;
74
- }
75
- }
76
- if (border.right) {
77
- if (border.right.color != null && border.right.color != "" && !ignoringStyle.includes("borderRightColor")) {
78
- style["border-right-color"] = border.right.color;
79
- }
80
- if (border.right.width != null && border.right.width != "" && !ignoringStyle.includes("borderRightWidth")) {
81
- style["border-right-width"] = border.right.width;
82
- }
83
- if (border.right.style && !ignoringStyle.includes("borderRightStyle")) {
84
- style["border-right-style"] = border.right.style;
85
- }
86
- }
87
- if (border.bottom) {
88
- if (border.bottom.color != null && border.bottom.color != "" && !ignoringStyle.includes("borderBottomColor")) {
89
- style["border-bottom-color"] = border.bottom.color;
90
- }
91
- if (border.bottom.width != null && border.bottom.width != "" && !ignoringStyle.includes("borderBottomWidth")) {
92
- style["border-bottom-width"] = border.bottom.width;
93
- }
94
- if (border.bottom.style && !ignoringStyle.includes("borderBottomStyle")) {
95
- style["border-bottom-style"] = border.bottom.style;
96
- }
97
- }
98
- if (border.left) {
99
- if (border.left.color != null && border.left.color != "" && !ignoringStyle.includes("borderLeftColor")) {
100
- style["border-left-color"] = border.left.color;
101
- }
102
- if (border.left.width != null && border.left.width != "" && !ignoringStyle.includes("borderLeftWidth")) {
103
- style["border-left-width"] = border.left.width;
104
- }
105
- if (border.left.style && !ignoringStyle.includes("borderLeftStyle")) {
106
- style["border-left-style"] = border.left.style;
107
- }
108
- }
109
- }
110
- if (data.border_radius) {
111
- style["border-radius"] = `${data.border_radius}px`;
112
- }
113
- return style;
1
+ //#region src/utils/style/index.ts
2
+ /**
3
+ * 计算配置样式
4
+ *
5
+ * @param data
6
+ * @param ignoringStyle 忽略计算的样式
7
+ * @returns
8
+ */
9
+ var calcStyle = (data, ignoringStyle = []) => {
10
+ const style = {};
11
+ const padding = data.padding;
12
+ if (padding) {
13
+ if (padding.top != null && padding.top != "" && !ignoringStyle.includes("paddingTop")) style["padding-top"] = padding.top;
14
+ if (padding.right != null && padding.right != "" && !ignoringStyle.includes("paddingRight")) style["padding-right"] = padding.right;
15
+ if (padding.bottom != null && padding.bottom != "" && !ignoringStyle.includes("paddingBottom")) style["padding-bottom"] = padding.bottom;
16
+ if (padding.left != null && padding.left != "" && !ignoringStyle.includes("paddingLeft")) style["padding-left"] = padding.left;
17
+ }
18
+ const margin = data.margin;
19
+ if (margin) {
20
+ if (margin.top != null && margin.top != "" && !ignoringStyle.includes("marginTop")) style["margin-top"] = margin.top;
21
+ if (margin.right != null && margin.right != "" && !ignoringStyle.includes("marginRight")) style["margin-right"] = margin.right;
22
+ if (margin.bottom != null && margin.bottom != "" && !ignoringStyle.includes("marginBottom")) style["margin-bottom"] = margin.bottom;
23
+ if (margin.left != null && margin.left != "" && !ignoringStyle.includes("marginLeft")) style["margin-left"] = margin.left;
24
+ }
25
+ if (data.background != null && data.background != "" && !ignoringStyle.includes("backgroundColor")) style["background-color"] = data.background;
26
+ if (data.width != null && data.width != "" && !ignoringStyle.includes("width")) style.width = data.width;
27
+ if (data.height != null && data.height != "" && !ignoringStyle.includes("height")) {
28
+ style.height = data.height;
29
+ style.overflowX = "hidden";
30
+ style.overflowY = "auto";
31
+ }
32
+ const position = data.position;
33
+ if (position) {
34
+ if (position.position != null && position.position != "" && !ignoringStyle.includes("zIndex")) {
35
+ style.position = position.position;
36
+ style["z-index"] = 1;
37
+ }
38
+ if (position.top != null && position.top != "" && !ignoringStyle.includes("top")) style.top = `${position.top}px`;
39
+ if (position.right != null && position.right != "" && !ignoringStyle.includes("right")) style.right = `${position.right}px`;
40
+ if (position.bottom != null && position.bottom != "" && !ignoringStyle.includes("bottom")) style.bottom = `${position.bottom}px`;
41
+ if (position.left != null && position.left != "" && !ignoringStyle.includes("left")) style.left = `${position.left}px`;
42
+ }
43
+ const border = data.border;
44
+ if (border) {
45
+ if (border.topLeftRadius != null && border.topLeftRadius != "" && !ignoringStyle.includes("borderTopLeftRadius")) style["border-top-left-radius"] = border.topLeftRadius;
46
+ if (border.topRightRadius != null && border.topRightRadius != "" && !ignoringStyle.includes("borderTopRightRadius")) style["border-top-right-radius"] = border.topRightRadius;
47
+ if (border.bottomLeftRadius != null && border.bottomLeftRadius != "" && !ignoringStyle.includes("borderBottomLeftRadius")) style["border-bottom-left-radius"] = border.bottomLeftRadius;
48
+ if (border.bottomRightRadius != null && border.bottomRightRadius != "" && !ignoringStyle.includes("borderBottomRightRadius")) style["border-bottom-right-radius"] = border.bottomRightRadius;
49
+ if (border.top) {
50
+ if (border.top.color != null && border.top.color != "" && !ignoringStyle.includes("borderTopColor")) style["border-top-color"] = border.top.color;
51
+ if (border.top.width != null && border.top.width != "" && !ignoringStyle.includes("borderTopWidth")) style["border-top-width"] = border.top.width;
52
+ if (border.top.style && !ignoringStyle.includes("borderTopStyle")) style["border-top-style"] = border.top.style;
53
+ }
54
+ if (border.right) {
55
+ if (border.right.color != null && border.right.color != "" && !ignoringStyle.includes("borderRightColor")) style["border-right-color"] = border.right.color;
56
+ if (border.right.width != null && border.right.width != "" && !ignoringStyle.includes("borderRightWidth")) style["border-right-width"] = border.right.width;
57
+ if (border.right.style && !ignoringStyle.includes("borderRightStyle")) style["border-right-style"] = border.right.style;
58
+ }
59
+ if (border.bottom) {
60
+ if (border.bottom.color != null && border.bottom.color != "" && !ignoringStyle.includes("borderBottomColor")) style["border-bottom-color"] = border.bottom.color;
61
+ if (border.bottom.width != null && border.bottom.width != "" && !ignoringStyle.includes("borderBottomWidth")) style["border-bottom-width"] = border.bottom.width;
62
+ if (border.bottom.style && !ignoringStyle.includes("borderBottomStyle")) style["border-bottom-style"] = border.bottom.style;
63
+ }
64
+ if (border.left) {
65
+ if (border.left.color != null && border.left.color != "" && !ignoringStyle.includes("borderLeftColor")) style["border-left-color"] = border.left.color;
66
+ if (border.left.width != null && border.left.width != "" && !ignoringStyle.includes("borderLeftWidth")) style["border-left-width"] = border.left.width;
67
+ if (border.left.style && !ignoringStyle.includes("borderLeftStyle")) style["border-left-style"] = border.left.style;
68
+ }
69
+ }
70
+ if (data.border_radius) style["border-radius"] = `${data.border_radius}px`;
71
+ return style;
114
72
  };
115
- const calcFontStyle = (data, ignoringStyle = []) => {
116
- const style = {};
117
- const labelFont = data.labelFont;
118
- if (labelFont) {
119
- if (labelFont.color != null && labelFont.color != "" && !ignoringStyle.includes("color"))
120
- style.color = labelFont.color;
121
- if (labelFont.fontSize != null && labelFont.fontSize != "" && !ignoringStyle.includes("fontSize")) {
122
- style["font-size"] = labelFont.fontSize;
123
- }
124
- if (labelFont.align && !ignoringStyle.includes("textAlign")) {
125
- style["text-align"] = labelFont.align;
126
- style["text-align-last"] = labelFont.align;
127
- }
128
- if (labelFont.bold === true && !ignoringStyle.includes("fontWeight")) {
129
- style["font-weight"] = "bold";
130
- }
131
- if (labelFont.italic === true && !ignoringStyle.includes("fontStyle")) {
132
- style["font-style"] = "italic";
133
- }
134
- if (labelFont.textDecoration && !ignoringStyle.includes("textDecoration")) {
135
- style["text-decoration"] = labelFont.textDecoration;
136
- }
137
- }
138
- return style;
73
+ /**
74
+ * 计算字体样式
75
+ *
76
+ * @param data
77
+ * @param ignoringStyle 忽略的样式
78
+ * @returns
79
+ */
80
+ var calcFontStyle = (data, ignoringStyle = []) => {
81
+ const style = {};
82
+ const labelFont = data.labelFont;
83
+ if (labelFont) {
84
+ if (labelFont.color != null && labelFont.color != "" && !ignoringStyle.includes("color")) style.color = labelFont.color;
85
+ if (labelFont.fontSize != null && labelFont.fontSize != "" && !ignoringStyle.includes("fontSize")) style["font-size"] = labelFont.fontSize;
86
+ if (labelFont.align && !ignoringStyle.includes("textAlign")) {
87
+ style["text-align"] = labelFont.align;
88
+ style["text-align-last"] = labelFont.align;
89
+ }
90
+ if (labelFont.bold === true && !ignoringStyle.includes("fontWeight")) style["font-weight"] = "bold";
91
+ if (labelFont.italic === true && !ignoringStyle.includes("fontStyle")) style["font-style"] = "italic";
92
+ if (labelFont.textDecoration && !ignoringStyle.includes("textDecoration")) style["text-decoration"] = labelFont.textDecoration;
93
+ }
94
+ return style;
139
95
  };
140
-
96
+ //#endregion
141
97
  export { calcFontStyle, calcStyle };
@@ -1,72 +1,104 @@
1
- import { getCookie, setCookie, clearCookie } from 'qx-util';
2
- import { mergeWith, cloneDeep, unionWith, isEqual } from 'lodash-es';
3
- import '../../constants/expression-type/modeCfg.mjs';
4
- import '../../constants/expression-type/BuiltOperators.mjs';
5
- import '../../constants/expression-type/function.mjs';
6
- import '../../constants/expression-type/variable.mjs';
7
- import { CoreConst } from '../../constants/core.mjs';
8
- import '../../enums/app-designer/index.mjs';
9
- import '../../enums/page-designer/designer.mjs';
10
- import '../../enums/breakpointEnum.mjs';
11
- import { TIMEZONE_KEY } from '../../enums/cacheEnum.mjs';
12
- import qs from 'qs';
13
-
1
+ import "../../enums/cacheEnum.mjs";
2
+ import "../../enums/index.mjs";
3
+ import { CoreConst } from "../../constants/core.mjs";
4
+ import "../../constants/index.mjs";
5
+ import qs from "qs";
6
+ import { cloneDeep, isEqual, mergeWith, unionWith } from "lodash-es";
7
+ import { clearCookie, getCookie, setCookie } from "qx-util";
8
+ //#region src/utils/tools/tools.ts
9
+ /**
10
+ * 获取认证令牌
11
+ *
12
+ * @export
13
+ * @returns {*} {(string | null)}
14
+ */
14
15
  function getToken() {
15
- return getCookie(CoreConst.TOKEN);
16
+ return getCookie(CoreConst.TOKEN);
16
17
  }
18
+ /**
19
+ * 设置认证令牌(目前只有 session 级别生效)
20
+ *
21
+ * @export
22
+ * @param {string} token
23
+ */
17
24
  function setToken(token) {
18
- if (token) {
19
- setCookie(CoreConst.TOKEN, token, 7, true);
20
- } else {
21
- clearCookie(CoreConst.TOKEN, true);
22
- }
25
+ if (token) setCookie(CoreConst.TOKEN, token, 7, true);
26
+ else clearCookie(CoreConst.TOKEN, true);
23
27
  }
28
+ /**
29
+ * 从 cookie 获取租户标识
30
+ *
31
+ * @export
32
+ * @returns {*} {(string | null)}
33
+ */
24
34
  function getTenant() {
25
- return getCookie(CoreConst.TENANT);
35
+ return getCookie(CoreConst.TENANT);
26
36
  }
37
+ /**
38
+ * 设置租户标识至 cookie
39
+ *
40
+ * @export
41
+ * @param {string} tenant
42
+ */
27
43
  function setTenant(tenant) {
28
- if (tenant) {
29
- setCookie(CoreConst.TENANT, tenant, 7, true);
30
- } else {
31
- clearCookie(CoreConst.TENANT, true);
32
- }
44
+ if (tenant) setCookie(CoreConst.TENANT, tenant, 7, true);
45
+ else clearCookie(CoreConst.TENANT, true);
33
46
  }
34
- const isMobile = (() => {
35
- const ua = navigator.userAgent;
36
- const mobileRegex = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/;
37
- const isSmallScreen = window.innerWidth <= 768;
38
- const isTouch = "ontouchstart" in window || navigator.maxTouchPoints > 0;
39
- return mobileRegex.test(ua) || isSmallScreen && isTouch;
47
+ /**
48
+ * 是否为移动端设备
49
+ */
50
+ var isMobile = (() => {
51
+ const ua = navigator.userAgent;
52
+ const mobileRegex = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/;
53
+ const isSmallScreen = window.innerWidth <= 768;
54
+ const isTouch = "ontouchstart" in window || navigator.maxTouchPoints > 0;
55
+ return mobileRegex.test(ua) || isSmallScreen && isTouch;
40
56
  })();
57
+ /**
58
+ * 获取时区,默认: UTC+08:00
59
+ *
60
+ * @export
61
+ * @returns {*}
62
+ */
41
63
  function getTimezone() {
42
- return localStorage.getItem(TIMEZONE_KEY) || "UTC+08:00";
64
+ return localStorage.getItem("TIMEZONE__") || "UTC+08:00";
43
65
  }
66
+ /**
67
+ * 递归合并两个对象
68
+ *
69
+ * @template T
70
+ * @template U
71
+ * @param {T} target 目标对象,合并后结果存放于此
72
+ * @param {U} source 要合并的源对象
73
+ * @returns {(T & U)} 合并后的对象
74
+ */
44
75
  function deepMerge(target, source) {
45
- return mergeWith(cloneDeep(target), source, (objValue, srcValue) => {
46
- if (typeof objValue === "object" && typeof srcValue === "object") {
47
- return mergeWith(
48
- cloneDeep(objValue),
49
- srcValue,
50
- (prevValue, nextValue) => {
51
- return Array.isArray(prevValue) ? unionWith(prevValue, nextValue, isEqual) : void 0;
52
- }
53
- );
54
- }
55
- });
76
+ return mergeWith(cloneDeep(target), source, (objValue, srcValue) => {
77
+ if (typeof objValue === "object" && typeof srcValue === "object") return mergeWith(cloneDeep(objValue), srcValue, (prevValue, nextValue) => {
78
+ return Array.isArray(prevValue) ? unionWith(prevValue, nextValue, isEqual) : void 0;
79
+ });
80
+ });
56
81
  }
82
+ /**
83
+ * 对象 → 矩阵参数(stringify)
84
+ * @param {*} params
85
+ * @returns
86
+ */
57
87
  function stringifyMatrixParams(params) {
58
- const str = qs.stringify(params, {
59
- encode: true,
60
- delimiter: ";"
61
- });
62
- return str ? `;${str}` : "";
88
+ const str = qs.stringify(params, {
89
+ encode: true,
90
+ delimiter: ";"
91
+ });
92
+ return str ? `;${str}` : "";
63
93
  }
94
+ /**
95
+ * 矩阵参数 → 对象(parse)
96
+ * @param {*} path
97
+ * @returns
98
+ */
64
99
  function parseMatrixParams(path) {
65
- const idx = path.indexOf(";");
66
- if (idx === -1) return {};
67
- return qs.parse(path, {
68
- delimiter: ";"
69
- });
100
+ if (path.indexOf(";") === -1) return {};
101
+ return qs.parse(path, { delimiter: ";" });
70
102
  }
71
-
103
+ //#endregion
72
104
  export { deepMerge, getTenant, getTimezone, getToken, isMobile, parseMatrixParams, setTenant, setToken, stringifyMatrixParams };