@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,93 +1,85 @@
1
- import { computed, unref } from 'vue';
2
-
3
- const randomUUID = (uuids = [], opts) => {
4
- const {
5
- needPrefix = false,
6
- isString = true,
7
- prefix = "u_",
8
- length = 8,
9
- chars = "",
10
- numPref = false
11
- } = opts || {};
12
- let characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
13
- if (chars === "capital&number") {
14
- characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
15
- } else if (chars === "lowercase&number") {
16
- characters = "abcdefghijklmnopqrstuvwxyz0123456789";
17
- } else if (chars === "lowercase") {
18
- characters = "abcdefghijklmnopqrstuvwxyz";
19
- }
20
- let uuid;
21
- while (!uuid) {
22
- let id = "";
23
- if (isString) {
24
- if (numPref) {
25
- id += Math.floor(Math.random() * 9) + 1;
26
- }
27
- for (let i = 0; i < length; i++) {
28
- id += characters.charAt(Math.floor(Math.random() * characters.length));
29
- }
30
- } else {
31
- id = `${needPrefix ? prefix : ""}${numPref ? Math.floor(Math.random() * 9) + 1 : ""}${Math.random().toString(36).substr(2, length)}`;
32
- }
33
- if (!uuids.includes(id)) {
34
- uuid = id;
35
- }
36
- }
37
- return uuid;
1
+ import { computed, unref } from "vue";
2
+ //#region src/utils/useUUid.ts
3
+ /**
4
+ * 生成随机串
5
+ * @param uuids 不可用的uuid
6
+ * @param opts
7
+ * @param opts.needPrefix 是否需要拼接前缀(默认不需要)
8
+ * @param opts.isString 随机串只能是字符串
9
+ * @param opts.prefix 前缀,默认前缀u_
10
+ * @param opts.length 即将生成的uuid位数(不包含前缀, 默认8位)
11
+ * @param opts.chars 类型
12
+ * @param opts.numPref 数字打头
13
+ */
14
+ var randomUUID = (uuids = [], opts) => {
15
+ const { needPrefix = false, isString = true, prefix = "u_", length = 8, chars = "", numPref = false } = opts || {};
16
+ let characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
17
+ if (chars === "capital&number") characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
18
+ else if (chars === "lowercase&number") characters = "abcdefghijklmnopqrstuvwxyz0123456789";
19
+ else if (chars === "lowercase") characters = "abcdefghijklmnopqrstuvwxyz";
20
+ let uuid;
21
+ while (!uuid) {
22
+ let id = "";
23
+ if (isString) {
24
+ if (numPref) id += Math.floor(Math.random() * 9) + 1;
25
+ for (let i = 0; i < length; i++) id += characters.charAt(Math.floor(Math.random() * characters.length));
26
+ } else id = `${needPrefix ? prefix : ""}${numPref ? Math.floor(Math.random() * 9) + 1 : ""}${Math.random().toString(36).substr(2, length)}`;
27
+ if (!uuids.includes(id)) uuid = id;
28
+ }
29
+ return uuid;
38
30
  };
31
+ /**
32
+ * uuid生成器
33
+ * @param uuids 已有uuid
34
+ */
39
35
  randomUUID.Generate = (uuids, opts) => {
40
- const cloneUUids = Array.isArray(uuids) ? uuids.concat() : [];
41
- return {
42
- next: () => {
43
- const id = randomUUID(cloneUUids, opts);
44
- cloneUUids.push(id);
45
- return id;
46
- }
47
- };
36
+ const cloneUUids = Array.isArray(uuids) ? uuids.concat() : [];
37
+ return { next: () => {
38
+ const id = randomUUID(cloneUUids, opts);
39
+ cloneUUids.push(id);
40
+ return id;
41
+ } };
48
42
  };
49
43
  function useUUid(tableData, keyAttr, opts) {
50
- const f_children = "children";
51
- const f_key = "key";
52
- const flatTableData = computed(() => {
53
- return tableData.value.reduce((list, item) => {
54
- list.push(item);
55
- const nodes = item[f_children].map((ele) => {
56
- return {
57
- ...ele,
58
- _pid_: item.id
59
- };
60
- });
61
- list.push(...nodes);
62
- return list;
63
- }, []);
64
- });
65
- const oldUUids = computed(() => {
66
- return flatTableData.value.map((data) => {
67
- if (data._pid_) {
68
- return data[f_key].replace(new RegExp(`^${unref(keyAttr)}_*`), "");
69
- }
70
- return null;
71
- }).filter((i) => i);
72
- });
73
- function getUuid(uuidsProp, optsProp) {
74
- return randomUUID([...unref(oldUUids), ...uuidsProp ?? []], {
75
- ...opts,
76
- ...optsProp
77
- });
78
- }
79
- function getUuidGenerate(uuidsProp, optsProp) {
80
- return randomUUID.Generate([...unref(oldUUids), ...uuidsProp ?? []], {
81
- ...opts,
82
- ...optsProp
83
- });
84
- }
85
- return {
86
- oldUUids,
87
- flatTableData,
88
- getUuid,
89
- getUuidGenerate
90
- };
44
+ const f_children = "children";
45
+ const f_key = "key";
46
+ const flatTableData = computed(() => {
47
+ return tableData.value.reduce((list, item) => {
48
+ list.push(item);
49
+ const nodes = item[f_children].map((ele) => {
50
+ return {
51
+ ...ele,
52
+ _pid_: item.id
53
+ };
54
+ });
55
+ list.push(...nodes);
56
+ return list;
57
+ }, []);
58
+ });
59
+ const oldUUids = computed(() => {
60
+ return flatTableData.value.map((data) => {
61
+ if (data._pid_) return data[f_key].replace(new RegExp(`^${unref(keyAttr)}_*`), "");
62
+ return null;
63
+ }).filter((i) => i);
64
+ });
65
+ function getUuid(uuidsProp, optsProp) {
66
+ return randomUUID([...unref(oldUUids), ...uuidsProp ?? []], {
67
+ ...opts,
68
+ ...optsProp
69
+ });
70
+ }
71
+ function getUuidGenerate(uuidsProp, optsProp) {
72
+ return randomUUID.Generate([...unref(oldUUids), ...uuidsProp ?? []], {
73
+ ...opts,
74
+ ...optsProp
75
+ });
76
+ }
77
+ return {
78
+ oldUUids,
79
+ flatTableData,
80
+ getUuid,
81
+ getUuidGenerate
82
+ };
91
83
  }
92
-
84
+ //#endregion
93
85
  export { randomUUID, useUUid };
package/es/utils/util.mjs CHANGED
@@ -1,40 +1,60 @@
1
+ //#region src/utils/util.ts
2
+ /**
3
+ * 替换url中的参数,格式为xxx/{aid}/xxx/{pid}/{bid?}
4
+ *
5
+ * @export
6
+ * @param {string} url - 原始 URL 字符串
7
+ * @param {IObject} data - 用于替换占位符的数据对象
8
+ * @return {string} 处理后的 URL 字符串
9
+ */
1
10
  function genUrl(url, data) {
2
- let result = url;
3
- Object.keys(data).forEach((key) => {
4
- result = result.replace(`{${key}}`, data[key] ?? "");
5
- result = result.replace(`{${key}?}`, data[key] ?? "");
6
- });
7
- result = result.replace(/\/\{[a-z]+\?\}/g, "");
8
- return result;
11
+ let result = url;
12
+ Object.keys(data).forEach((key) => {
13
+ result = result.replace(`{${key}}`, data[key] ?? "");
14
+ result = result.replace(`{${key}?}`, data[key] ?? "");
15
+ });
16
+ result = result.replace(/\/\{[a-z]+\?\}/g, "");
17
+ return result;
9
18
  }
19
+ /**
20
+ * 打开新窗口
21
+ *
22
+ * @export
23
+ * @param {string} url - 要打开的 URL
24
+ * @param {IOpenWindowOptions} [options] - 窗口配置选项
25
+ * @return {Window | null} 新打开的窗口对象,如果打开失败则返回 null
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * // 简单打开新窗口
30
+ * openWindow('https://example.com');
31
+ *
32
+ * // 使用 URL 参数替换
33
+ * openWindow('/user/{id}/profile', {
34
+ * genUrlData: { id: '123' }
35
+ * });
36
+ *
37
+ * // 完整配置
38
+ * openWindow('https://example.com', {
39
+ * target: '_blank',
40
+ * noopener: true,
41
+ * noreferrer: true,
42
+ * routePath: '/dashboard',
43
+ * optionStr: 'width=800,height=600'
44
+ * });
45
+ * ```
46
+ */
10
47
  function openWindow(url, options) {
11
- const {
12
- target = "_blank",
13
- noopener = true,
14
- noreferrer = true,
15
- genUrlData,
16
- routePath = "",
17
- optionStr = ""
18
- } = options || {};
19
- const features = [];
20
- if (noopener) {
21
- features.push("noopener=yes");
22
- }
23
- if (noreferrer) {
24
- features.push("noreferrer=yes");
25
- }
26
- let finalUrl = url;
27
- if (genUrlData) {
28
- finalUrl = genUrl(finalUrl, genUrlData);
29
- }
30
- if (routePath) {
31
- finalUrl += routePath;
32
- }
33
- let featuresStr = features.join(",");
34
- if (optionStr) {
35
- featuresStr = featuresStr ? `${featuresStr},${optionStr}` : optionStr;
36
- }
37
- return window.open(finalUrl, target, featuresStr);
48
+ const { target = "_blank", noopener = true, noreferrer = true, genUrlData, routePath = "", optionStr = "" } = options || {};
49
+ const features = [];
50
+ if (noopener) features.push("noopener=yes");
51
+ if (noreferrer) features.push("noreferrer=yes");
52
+ let finalUrl = url;
53
+ if (genUrlData) finalUrl = genUrl(finalUrl, genUrlData);
54
+ if (routePath) finalUrl += routePath;
55
+ let featuresStr = features.join(",");
56
+ if (optionStr) featuresStr = featuresStr ? `${featuresStr},${optionStr}` : optionStr;
57
+ return window.open(finalUrl, target, featuresStr);
38
58
  }
39
-
59
+ //#endregion
40
60
  export { genUrl, openWindow };
@@ -1,3 +1,5 @@
1
+ import { sha256 } from 'js-sha256';
1
2
  export declare function buildUUID(): string;
2
3
  export declare function buildShortUUID(prefix?: string): string;
3
4
  export declare const uuid2: (len: number, radix?: number) => string;
5
+ export { sha256 };
@@ -1,48 +1,38 @@
1
- const hexList = [];
2
- for (let i = 0; i <= 15; i++) {
3
- hexList[i] = i.toString(16);
4
- }
1
+ import { sha256 } from "js-sha256";
2
+ //#region src/utils/uuid/uuid.ts
3
+ var hexList = [];
4
+ for (let i = 0; i <= 15; i++) hexList[i] = i.toString(16);
5
5
  function buildUUID() {
6
- let uuid = "";
7
- for (let i = 1; i <= 36; i++) {
8
- if (i === 9 || i === 14 || i === 19 || i === 24) {
9
- uuid += "-";
10
- } else if (i === 15) {
11
- uuid += 4;
12
- } else if (i === 20) {
13
- uuid += hexList[Math.random() * 4 | 8];
14
- } else {
15
- uuid += hexList[Math.random() * 16 | 0];
16
- }
17
- }
18
- return uuid.replace(/-/g, "");
6
+ let uuid = "";
7
+ for (let i = 1; i <= 36; i++) if (i === 9 || i === 14 || i === 19 || i === 24) uuid += "-";
8
+ else if (i === 15) uuid += 4;
9
+ else if (i === 20) uuid += hexList[Math.random() * 4 | 8];
10
+ else uuid += hexList[Math.random() * 16 | 0];
11
+ return uuid.replace(/-/g, "");
19
12
  }
20
- let unique = 0;
13
+ var unique = 0;
21
14
  function buildShortUUID(prefix = "") {
22
- prefix = prefix.replaceAll("-", "");
23
- const random = Math.floor(Math.random() * 1e9);
24
- unique++;
25
- return prefix + "_" + random + unique;
15
+ prefix = prefix.replaceAll("-", "");
16
+ const random = Math.floor(Math.random() * 1e9);
17
+ unique++;
18
+ return prefix + "_" + random + unique;
26
19
  }
27
- const uuid2 = (len, radix) => {
28
- const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");
29
- const uuid = [];
30
- let i;
31
- radix = radix || chars.length;
32
- if (len) {
33
- for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
34
- } else {
35
- let r;
36
- uuid[8] = uuid[13] = uuid[18] = uuid[23] = "-";
37
- uuid[14] = "4";
38
- for (i = 0; i < 36; i++) {
39
- if (!uuid[i]) {
40
- r = 0 | Math.random() * 16;
41
- uuid[i] = chars[i == 19 ? r & 3 | 8 : r];
42
- }
43
- }
44
- }
45
- return uuid.join("");
20
+ var uuid2 = (len, radix) => {
21
+ const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");
22
+ const uuid = [];
23
+ let i;
24
+ radix = radix || chars.length;
25
+ if (len) for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
26
+ else {
27
+ let r;
28
+ uuid[8] = uuid[13] = uuid[18] = uuid[23] = "-";
29
+ uuid[14] = "4";
30
+ for (i = 0; i < 36; i++) if (!uuid[i]) {
31
+ r = 0 | Math.random() * 16;
32
+ uuid[i] = chars[i == 19 ? r & 3 | 8 : r];
33
+ }
34
+ }
35
+ return uuid.join("");
46
36
  };
47
-
48
- export { buildShortUUID, buildUUID, uuid2 };
37
+ //#endregion
38
+ export { buildShortUUID, buildUUID, sha256, uuid2 };
@@ -1,25 +1,21 @@
1
- import { t } from './i18n/index.mjs';
2
-
3
- const validateEmoji = (value) => {
4
- const reg = /[\u{1F300}-\u{1F5FF}\u{1F600}-\u{1F64F}\u{1F680}-\u{1F6FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/gu;
5
- const reg2 = /\u{1F91D}\u{1F3FB}-\u{1F3FF}/u;
6
- return reg.test(value) || reg2.test(value);
1
+ import { t } from "./i18n/index.mjs";
2
+ //#region src/utils/validate.ts
3
+ var validateEmoji = (value) => {
4
+ return /[\u{1F300}-\u{1F5FF}\u{1F600}-\u{1F64F}\u{1F680}-\u{1F6FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/gu.test(value) || /\u{1F91D}\u{1F3FB}-\u{1F3FF}/u.test(value);
7
5
  };
8
- const hasEmojiAndSpecStr = (value) => {
9
- return validateEmoji(value) || /[*??::,,[\]【】#]/.test(value);
6
+ var hasEmojiAndSpecStr = (value) => {
7
+ return validateEmoji(value) || /[*??::,,[\]【】#]/.test(value);
10
8
  };
11
- const hasEmojiAndSpecStr1 = (value) => {
12
- return validateEmoji(value) || /[*??::,,[\]\\/【】#]/.test(value);
9
+ var hasEmojiAndSpecStr1 = (value) => {
10
+ return validateEmoji(value) || /[*??::,,[\]\\/【】#]/.test(value);
13
11
  };
14
- const validateModelName = (_rule, value) => {
15
- if (hasEmojiAndSpecStr(value))
16
- return Promise.reject(t("sys.model.modelNameError"));
17
- return Promise.resolve();
12
+ var validateModelName = (_rule, value) => {
13
+ if (hasEmojiAndSpecStr(value)) return Promise.reject(t("sys.model.modelNameError"));
14
+ return Promise.resolve();
18
15
  };
19
- const validateIsModelName = (_rule, value) => {
20
- if (hasEmojiAndSpecStr1(value))
21
- return Promise.reject(t("sys.model.notModelNameError"));
22
- return Promise.resolve();
16
+ var validateIsModelName = (_rule, value) => {
17
+ if (hasEmojiAndSpecStr1(value)) return Promise.reject(t("sys.model.notModelNameError"));
18
+ return Promise.resolve();
23
19
  };
24
-
20
+ //#endregion
25
21
  export { hasEmojiAndSpecStr, hasEmojiAndSpecStr1, validateEmoji, validateIsModelName, validateModelName };
@@ -1,111 +1,126 @@
1
- import { isRef, computed, ref, watch } from 'vue';
2
-
1
+ import { computed, isRef, ref, watch } from "vue";
2
+ //#region src/utils/value-helper/value-helper.ts
3
3
  function afterValueSet(value, afterSet) {
4
- const newVal = computed({
5
- get: () => value.value,
6
- set: (v) => {
7
- value.value = v;
8
- afterSet(v);
9
- }
10
- });
11
- return newVal;
4
+ return computed({
5
+ get: () => value.value,
6
+ set: (v) => {
7
+ value.value = v;
8
+ afterSet(v);
9
+ }
10
+ });
12
11
  }
13
12
  function afterFieldSet(object, afterSet) {
14
- const keys = Object.keys(isRef(object) ? object.value : object);
15
- const result = {};
16
- keys.forEach((key) => {
17
- result[key] = computed({
18
- get: () => {
19
- return (isRef(object) ? object.value : object)[key];
20
- },
21
- set(v) {
22
- (isRef(object) ? object.value : object)[key] = v;
23
- afterSet(key, v);
24
- }
25
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
- });
27
- });
28
- return result;
13
+ const keys = Object.keys(isRef(object) ? object.value : object);
14
+ const result = {};
15
+ keys.forEach((key) => {
16
+ result[key] = computed({
17
+ get: () => {
18
+ return (isRef(object) ? object.value : object)[key];
19
+ },
20
+ set(v) {
21
+ (isRef(object) ? object.value : object)[key] = v;
22
+ afterSet(key, v);
23
+ }
24
+ });
25
+ });
26
+ return result;
29
27
  }
28
+ /**
29
+ * 属性修改的时候不修改并抛出事件
30
+ * @author lingxiaoming
31
+ * @date 2024-07-17 03:30:44
32
+ * @export
33
+ * @template T
34
+ * @param {(T | Ref<T>)} object (对象必须有该属性,即使是undefined,否则无法监控)
35
+ * @param {<F extends keyof T>(field: F, v: T[F], newObj: T) => void} emitSet newObj是将要修改成的完整数据
36
+ * @return {*} {ToRefs<T>}
37
+ */
30
38
  function emitFieldSet(object, emitSet) {
31
- const keys = Object.keys(isRef(object) ? object.value : object);
32
- const result = {};
33
- let cacheData = {};
34
- keys.forEach((key) => {
35
- result[key] = computed({
36
- get: () => {
37
- cacheData = {};
38
- return (isRef(object) ? object.value : object)[key];
39
- },
40
- set(v) {
41
- const objVal = isRef(object) ? object.value : object;
42
- cacheData[key] = v;
43
- const newObj = { ...objVal, ...cacheData };
44
- emitSet(key, v, newObj);
45
- }
46
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
- });
48
- });
49
- return result;
39
+ const keys = Object.keys(isRef(object) ? object.value : object);
40
+ const result = {};
41
+ let cacheData = {};
42
+ keys.forEach((key) => {
43
+ result[key] = computed({
44
+ get: () => {
45
+ cacheData = {};
46
+ return (isRef(object) ? object.value : object)[key];
47
+ },
48
+ set(v) {
49
+ const objVal = isRef(object) ? object.value : object;
50
+ cacheData[key] = v;
51
+ emitSet(key, v, {
52
+ ...objVal,
53
+ ...cacheData
54
+ });
55
+ }
56
+ });
57
+ });
58
+ return result;
50
59
  }
60
+ /**
61
+ * 解析数值和单位
62
+ * @author lingxiaoming
63
+ * @date 2024-07-15 06:06:41
64
+ * @param {string} str
65
+ * @return {*} {({ value: number; unit: string } | null)}
66
+ */
51
67
  function parseValueUnit(str) {
52
- if (str === "nullpx") {
53
- return {
54
- value: 0,
55
- unit: "px"
56
- };
57
- }
58
- const regex = /^(\d+\.?\d*)([a-zA-Z%]+)$/;
59
- const match = str.match(regex);
60
- if (match) {
61
- return {
62
- value: parseFloat(match[1]),
63
- unit: match[2]
64
- };
65
- }
66
- throw new Error("Invalid value");
68
+ if (str === "nullpx") return {
69
+ value: 0,
70
+ unit: "px"
71
+ };
72
+ const match = str.match(/^(\d+\.?\d*)([a-zA-Z%]+)$/);
73
+ if (match) return {
74
+ value: parseFloat(match[1]),
75
+ unit: match[2]
76
+ };
77
+ throw new Error("Invalid value");
67
78
  }
79
+ /**
80
+ * 增强computed,当属性变更时,自动调用set方法
81
+ * @author lingxiaoming
82
+ * @date 2024-08-26 10:19:01
83
+ * @export
84
+ * @param {{
85
+ * get: ComputedGetter<T>;
86
+ * set: ComputedSetter<T>;
87
+ * deep: boolean; //为true时,深层属性变更也会触发set
88
+ * }} opts
89
+ */
68
90
  function computedEx(opts) {
69
- const result = ref();
70
- let clear;
71
- const watchDeep = () => {
72
- if (!opts.deep) {
73
- return;
74
- }
75
- clear = watch(
76
- () => result.value,
77
- (v) => {
78
- console.info("computedEx:属性或者值修改", v);
79
- opts.set(v);
80
- },
81
- { deep: true }
82
- );
83
- };
84
- watch(
85
- () => opts.get(),
86
- (v) => {
87
- if (clear) {
88
- clear();
89
- }
90
- console.info("computedEx:获取新值,重新监听", v);
91
- result.value = v;
92
- watchDeep();
93
- },
94
- { immediate: true }
95
- );
96
- return result;
91
+ const result = ref();
92
+ let clear;
93
+ const watchDeep = () => {
94
+ if (!opts.deep) return;
95
+ clear = watch(() => result.value, (v) => {
96
+ console.info("computedEx:属性或者值修改", v);
97
+ opts.set(v);
98
+ }, { deep: true });
99
+ };
100
+ watch(() => opts.get(), (v) => {
101
+ if (clear) clear();
102
+ console.info("computedEx:获取新值,重新监听", v);
103
+ result.value = v;
104
+ watchDeep();
105
+ }, { immediate: true });
106
+ return result;
97
107
  }
108
+ /**
109
+ * 缓存函数返回值,下次相同参数调用时直接返回缓存值
110
+ * @export
111
+ * @template T
112
+ * @param cb
113
+ * @return {*}
114
+ */
98
115
  function cacheFnReturn(cb) {
99
- const cacheReturn = /* @__PURE__ */ new Map();
100
- return function(...args) {
101
- const key = JSON.stringify(args);
102
- if (cacheReturn.has(key)) {
103
- return cacheReturn.get(key);
104
- }
105
- const result = cb(...args);
106
- cacheReturn.set(key, result);
107
- return result;
108
- };
116
+ const cacheReturn = /* @__PURE__ */ new Map();
117
+ return function(...args) {
118
+ const key = JSON.stringify(args);
119
+ if (cacheReturn.has(key)) return cacheReturn.get(key);
120
+ const result = cb(...args);
121
+ cacheReturn.set(key, result);
122
+ return result;
123
+ };
109
124
  }
110
-
125
+ //#endregion
111
126
  export { afterFieldSet, afterValueSet, cacheFnReturn, computedEx, emitFieldSet, parseValueUnit };