lan-low-code-cli 2.0.0 → 2.1.0
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/README.md +1 -0
- package/dist/generator/index.js +19 -6
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -453,6 +453,7 @@ llc form autofill --id <fdId> --apply --publish --action-file ./actions.json
|
|
|
453
453
|
| 函数签名 | 控件级 `function onChange(value, rowNum)`(value 当前值,rowNum 明细行号);运行时闭包内可用 `MKXFORM`(如 `MKXFORM.setValue('表名.字段名', v)`) |
|
|
454
454
|
| key | `表名.控件uuid`(与运行时 `addActionToControlProps` 的查找规则一致);明细表字段同样适用 |
|
|
455
455
|
| 函数重名 | 自动追加随机后缀(与前端 `mergeControlAction` 行为一致) |
|
|
456
|
+
| 函数命名 | 控件级动作禁止裸事件名(`onChange` 等)——CLI 自动规范为 `onChange_<控件id>` 并同步重写函数源码声明;`$global` 全局动作保持裸事件名(如 `onLoad`) |
|
|
456
457
|
| 目标字段不存在 | 跳过并告警,不阻断 |
|
|
457
458
|
| 已有动作 | **保留**。`autofill` 会加载已有 `formAttr` 合并写入,不会清掉设计器里配置的动作/表单规则 |
|
|
458
459
|
|
package/dist/generator/index.js
CHANGED
|
@@ -966,16 +966,29 @@ function applyControlActions(formAttr, targets, actions) {
|
|
|
966
966
|
const warnings = [];
|
|
967
967
|
let completed = 0;
|
|
968
968
|
for (const action of actions) {
|
|
969
|
-
// 函数名:显式指定 > 源码解析 >
|
|
970
|
-
|
|
969
|
+
// 函数名:显式指定 > 源码解析 > 自动生成
|
|
970
|
+
let rawName = action.name ??
|
|
971
971
|
extractFunctionName(action.source) ??
|
|
972
972
|
`${action.event}_${action.target.replace(/[^\w]/g, '_')}`;
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
973
|
+
let source = action.source;
|
|
974
|
+
// 命名规范:禁止裸事件名(onChange / onClick / onLoad 等)——无法分辨触发控件。
|
|
975
|
+
// 统一追加控件 ID:onChange -> onChange_<fdName>($global 全局动作保持裸事件名,不做后缀)
|
|
976
|
+
if (action.target !== exports.ACTION_GLOBAL_TARGET && /^on[A-Z][a-zA-Z0-9]*$/.test(rawName)) {
|
|
977
|
+
const suffix = action.target === exports.ACTION_GLOBAL_TARGET ? 'global' : action.target;
|
|
978
|
+
const normalized = `${rawName}_${suffix}`;
|
|
979
|
+
// 同步重写源码中的函数声明,保持 JS 面板展示一致(仅替换声明处,不影响函数体)
|
|
980
|
+
const decl = `function ${rawName}(`;
|
|
981
|
+
if (source.includes(decl))
|
|
982
|
+
source = source.replace(decl, `function ${normalized}(`);
|
|
983
|
+
warnings.push(`动作函数名 "${rawName}" 无法分辨触发控件,已规范为 "${normalized}"`);
|
|
984
|
+
rawName = normalized;
|
|
985
|
+
}
|
|
986
|
+
const name = usedNames.has(rawName) ? `${rawName}_${(0, random_1.uuid)()}` : rawName;
|
|
987
|
+
if (name !== rawName) {
|
|
988
|
+
warnings.push(`动作函数重名:${rawName} 已重命名为 ${name}`);
|
|
976
989
|
}
|
|
977
990
|
usedNames.add(name);
|
|
978
|
-
const item = { name, id: (0, random_1.uuid)(), function:
|
|
991
|
+
const item = { name, id: (0, random_1.uuid)(), function: source };
|
|
979
992
|
if (action.target === exports.ACTION_GLOBAL_TARGET) {
|
|
980
993
|
;
|
|
981
994
|
(globalMap[_a = action.event] ?? (globalMap[_a] = [])).push(item);
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const field_1 = require("./commands/field");
|
|
|
9
9
|
const form_1 = require("./commands/form");
|
|
10
10
|
const locale_1 = require("./commands/locale");
|
|
11
11
|
const logger_1 = require("./utils/logger");
|
|
12
|
-
const VERSION = '2.
|
|
12
|
+
const VERSION = '2.1.0';
|
|
13
13
|
const program = new commander_1.Command();
|
|
14
14
|
exports.program = program;
|
|
15
15
|
program
|