fix: 修复 JSON 编辑页首次打开内容不完整的问题

main
sp mac bookpro 2605 2026-07-29 21:23:00 +08:00
parent 67e69d4d3b
commit c7c580a388
1 changed files with 9 additions and 5 deletions

View File

@ -130,7 +130,8 @@ export default function ExternalToolEditor({ open, agentId, plugin, onClose, onS
};
/**
*
* JSON
* JSON
*/
const handleAfterOpenChange = (visible: boolean) => {
if (!visible) return;
@ -171,11 +172,14 @@ export default function ExternalToolEditor({ open, agentId, plugin, onClose, onS
apis: [{ ...EMPTY_API }],
};
isSyncingRef.current = true;
// 初始化表单
form.setFieldsValue(initial);
setTimeout(() => {
isSyncingRef.current = false;
}, 0);
// 直接初始化 JSON 内容,避免首次进入 JSON 编辑页时显示为空或不完整
try {
setJsonContent(JSON.stringify(formValueToJson(initial), null, 2));
} catch (e) {
setJsonContent(JSON.stringify(initial, null, 2));
}
};
return (