@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.
- package/dist/index.esm.min.js +4522 -0
- package/es/constants/core.mjs +5 -4
- package/es/constants/default-date-type/default-date-type.mjs +73 -21
- package/es/constants/editor-register/editor-register.mjs +17 -5
- package/es/constants/expression-type/BuiltOperators.mjs +152 -147
- package/es/constants/expression-type/FunctionKeys.mjs +75 -79
- package/es/constants/expression-type/editor.mjs +10 -3
- package/es/constants/expression-type/function.mjs +602 -613
- package/es/constants/expression-type/index.mjs +111 -113
- package/es/constants/expression-type/modeCfg.mjs +256 -263
- package/es/constants/expression-type/variable.mjs +43 -39
- package/es/constants/form-container-type/form-container-type.mjs +17 -5
- package/es/constants/index.d.ts +1 -0
- package/es/constants/index.mjs +31 -10
- package/es/constants/page-designer/model.mjs +15 -5
- package/es/constants/page-designer/regex.d.ts +2 -0
- package/es/constants/page-designer/regex.mjs +5 -0
- package/es/create-app-vue.mjs +15 -9
- package/es/enums/app-designer/index.d.ts +19 -0
- package/es/enums/app-designer/index.mjs +131 -63
- package/es/enums/appEnum.mjs +681 -360
- package/es/enums/appStateEnum.mjs +17 -10
- package/es/enums/authActionEnum.mjs +63 -51
- package/es/enums/breakpointEnum.mjs +27 -26
- package/es/enums/cacheEnum.mjs +22 -21
- package/es/enums/designEnum.mjs +110 -71
- package/es/enums/developer-center/integration.mjs +7 -6
- package/es/enums/exceptionEnum.mjs +21 -17
- package/es/enums/expressionEnum.d.ts +1 -1
- package/es/enums/expressionEnum.mjs +81 -74
- package/es/enums/globalEnum.mjs +59 -36
- package/es/enums/httpEnum.mjs +71 -61
- package/es/enums/index.mjs +44 -14
- package/es/enums/menuEnum.mjs +42 -38
- package/es/enums/page-designer/designer.mjs +403 -407
- package/es/enums/page-designer/index.d.ts +1 -0
- package/es/enums/page-designer/index.mjs +5 -0
- package/es/enums/page-designer/layout.d.ts +12 -0
- package/es/enums/page-designer/layout.mjs +17 -0
- package/es/enums/page-designer/panel.mjs +341 -213
- package/es/enums/page-designer/toolkit.mjs +13 -12
- package/es/enums/page-designer/widget.mjs +425 -338
- package/es/enums/pageEnum.mjs +14 -13
- package/es/enums/plugin-enum.mjs +23 -7
- package/es/enums/processEnum.mjs +95 -60
- package/es/enums/roleEnum.mjs +7 -6
- package/es/enums/sizeEnum.d.ts +18 -0
- package/es/enums/sizeEnum.mjs +28 -8
- package/es/global/gct/gct.mjs +84 -96
- package/es/global/index.mjs +1 -0
- package/es/hooks/index.mjs +4 -0
- package/es/hooks/use-app-inst/use-app-inst.mjs +11 -5
- package/es/hooks/use-modal/use-modal.mjs +16 -10
- package/es/hooks/use-sub-app-utils/use-sub-app-utils.mjs +43 -23
- package/es/hooks/useCopyToClipboard.mjs +50 -50
- package/es/index.mjs +125 -114
- package/es/interface/i-pinia-state/i-global-state.d.ts +0 -11
- package/es/locale/index.mjs +50 -57
- package/es/modules/env-manager/env-manager.const.mjs +16 -8
- package/es/modules/env-manager/env-manager.d.ts +2 -0
- package/es/modules/env-manager/env-manager.interface.d.ts +2 -0
- package/es/modules/env-manager/env-manager.interface.mjs +14 -7
- package/es/modules/env-manager/env-manager.mjs +108 -107
- package/es/modules/error-handler/error-handler.const.mjs +11 -16
- package/es/modules/error-handler/error-strategy.mjs +199 -175
- package/es/modules/error-handler/index.mjs +120 -106
- package/es/modules/mqtt/constants/mqtt.const.mjs +21 -24
- package/es/modules/mqtt/enums/mqtt-status.enum.mjs +23 -9
- package/es/modules/mqtt/index.mjs +4 -0
- package/es/modules/mqtt/mqtt-client.mjs +228 -261
- package/es/modules/mqtt/mqtt-manager.mjs +117 -77
- package/es/modules/platform-config/constants/index.mjs +4 -0
- package/es/modules/platform-config/constants/login.const.mjs +48 -45
- package/es/modules/platform-config/constants/org.const.mjs +57 -52
- package/es/modules/platform-config/constants/theme.const.mjs +11 -4
- package/es/modules/platform-config/constants/watermark.const.mjs +17 -12
- package/es/modules/platform-config/enums/deploy.enum.mjs +13 -6
- package/es/modules/platform-config/enums/login.enum.mjs +29 -15
- package/es/modules/platform-config/enums/platform.enum.mjs +16 -13
- package/es/modules/platform-config/index.mjs +9 -0
- package/es/modules/platform-config/store.mjs +68 -79
- package/es/modules/platform-config/useBasicSetting.mjs +47 -35
- package/es/modules/platform-config/useDeploySetting.mjs +29 -21
- package/es/modules/platform-config/useLoginSetting.mjs +151 -173
- package/es/modules/platform-config/useOrgSetting.mjs +63 -62
- package/es/modules/platform-config/useProjectSetting.mjs +14 -6
- package/es/modules/platform-config/useSecuritySetting.mjs +68 -56
- package/es/modules/platform-config/useThemeSetting.mjs +78 -59
- package/es/modules/platform-config/useWatermarkSetting.mjs +37 -23
- package/es/modules/user-stores/index.mjs +3 -0
- package/es/modules/user-stores/store/permission.store.mjs +27 -36
- package/es/modules/user-stores/store/tenant.store.mjs +20 -22
- package/es/modules/user-stores/store/user.store.mjs +94 -117
- package/es/router/index.mjs +25 -28
- package/es/setup-app.mjs +23 -39
- package/es/state/global-pinia-state/global-pinia-state.d.ts +0 -6
- package/es/state/global-pinia-state/global-pinia-state.mjs +43 -71
- package/es/state/index.mjs +1 -0
- package/es/store/global-store.mjs +50 -72
- package/es/store/index.mjs +25 -19
- package/es/types/index.d.ts +7 -0
- package/es/utils/axios/interceptors.mjs +21 -17
- package/es/utils/cache-adapter/cache-adapter.mjs +61 -56
- package/es/utils/css-loader/css-loader.d.ts +36 -0
- package/es/utils/css-loader/css-loader.mjs +82 -0
- package/es/utils/design/design.mjs +18 -12
- package/es/utils/deviceFingerprint.mjs +77 -63
- package/es/utils/dictionary/dictionary.mjs +142 -145
- package/es/utils/file/base64Conver.mjs +35 -30
- package/es/utils/file/download.mjs +94 -98
- package/es/utils/file/parser.d.ts +3 -0
- package/es/utils/file/parser.mjs +29 -0
- package/es/utils/i18n/index.mjs +14 -3
- package/es/utils/index.d.ts +3 -1
- package/es/utils/index.mjs +32 -0
- package/es/utils/is-sort-filed/is-sort-filed.mjs +42 -37
- package/es/utils/linked-list/linked-list.mjs +115 -118
- package/es/utils/linked-node/linked-node.mjs +41 -31
- package/es/utils/lowcode/utils.mjs +13 -18
- package/es/utils/lowcode/validate.mjs +20 -26
- package/es/utils/mitt/mitt.mjs +4 -4
- package/es/utils/model-loader/model-loader.mjs +280 -325
- package/es/utils/namespace/namespace.mjs +178 -164
- package/es/utils/openUtil/index.mjs +2 -0
- package/es/utils/openUtil/modal/modal.mjs +72 -79
- package/es/utils/openUtil/overlay-container/overlay-container.mjs +144 -138
- package/es/utils/permission.mjs +33 -37
- package/es/utils/plugin-static-resource/plugin-static-resource.mjs +46 -42
- package/es/utils/style/index.mjs +94 -138
- package/es/utils/tools/tools.mjs +86 -54
- package/es/utils/treeHelper/treeHelper.mjs +205 -233
- package/es/utils/uploader/uploader.mjs +81 -115
- package/es/utils/useUUid.mjs +79 -87
- package/es/utils/util.mjs +55 -35
- package/es/utils/uuid/uuid.d.ts +2 -0
- package/es/utils/uuid/uuid.mjs +33 -43
- package/es/utils/validate.mjs +15 -19
- package/es/utils/value-helper/value-helper.mjs +113 -98
- package/package.json +9 -18
- package/dist/index.esm.min.mjs +0 -18322
- package/dist/index.min.cjs +0 -393
- package/dist/index.system.min.js +0 -393
package/es/utils/useUUid.mjs
CHANGED
|
@@ -1,93 +1,85 @@
|
|
|
1
|
-
import { computed, unref } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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 };
|
package/es/utils/uuid/uuid.d.ts
CHANGED
package/es/utils/uuid/uuid.mjs
CHANGED
|
@@ -1,48 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
13
|
+
var unique = 0;
|
|
21
14
|
function buildShortUUID(prefix = "") {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
prefix = prefix.replaceAll("-", "");
|
|
16
|
+
const random = Math.floor(Math.random() * 1e9);
|
|
17
|
+
unique++;
|
|
18
|
+
return prefix + "_" + random + unique;
|
|
26
19
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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 };
|
package/es/utils/validate.mjs
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import { t } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
9
|
-
|
|
6
|
+
var hasEmojiAndSpecStr = (value) => {
|
|
7
|
+
return validateEmoji(value) || /[*??::,,[\]【】#]/.test(value);
|
|
10
8
|
};
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
var hasEmojiAndSpecStr1 = (value) => {
|
|
10
|
+
return validateEmoji(value) || /[*??::,,[\]\\/【】#]/.test(value);
|
|
13
11
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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 {
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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 };
|