Files
eip4-platform/platform-converter/src
zhengwr 79eb8e2087 feat(converter): onEvent 脚本挂回改由 XML 事件绑定驱动,覆盖 NO_S3+按钮联动
WS-B Phase1-3:把老模板事件脚本按事件类型正确挂回 amis onEvent。

Phase1 解析:
- scriptKeyToSeq(Element):<scripts><script key> → key→1-based 文档序(对齐 rewriter 落盘 seq)。
- extractEventBindings(Element):递归收集 onselectedscript/onloadscript 属性 → List<EventBinding>(新增 public static EventBinding{eventType,scriptKey})。

Phase2 重写 attachScriptOnEvent(schema,templateId,List<EventBinding>,Map<key,seq>):
- onselectedscript → crud selectedChange,item=${event.data.selectedItems[0]}(行选中按钮联动)。
- onloadscript → inited,item=${&}(加载只读/显隐联动)。
- seq 由 keyToSeq 解析,引用不存在 key 则跳过(fail-closed);覆盖 NO_S3+FULL_AUTO,不再读 full_auto_index 决定挂哪段。
- scriptActionChain 重载支持自定义 item 表达式,原方法委托传 ${&}。
- 废弃旧「只挂 FULL_AUTO/每段同挂 inited+change」语义。

Phase3:buildToolbar 每按钮补 id=中文名(=label=enableButton 实参,三者同源),供 amis enabled/disabled 动作按 componentId 精准启停工具栏按钮。

BatchConvertCli:删 loadFullAutoIndex,改从每模板源 XML 解析 bindings+keyToSeq 调新 attach;rewriterDir 仍作 onEvent 总开关。

测试:platform-converter 85 绿(TemplateToAmisConverterTest 78,含新增 9 例:scriptKeyToSeq 文档序/extractEventBindings 收集/scriptActionChain 自定义 item/onselected→selectedChange+onload→inited/NO_S3 也挂/引用不存在 key 跳过/按钮含 id)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14 14:58:27 +08:00
..