From c7c580a388b6df5fc51151f05e9275ff2fdc466f Mon Sep 17 00:00:00 2001 From: sp mac bookpro 2605 Date: Wed, 29 Jul 2026 21:23:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20JSON=20=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E9=A1=B5=E9=A6=96=E6=AC=A1=E6=89=93=E5=BC=80=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E4=B8=8D=E5=AE=8C=E6=95=B4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ExternalToolEditor/index.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/ExternalToolEditor/index.tsx b/src/components/ExternalToolEditor/index.tsx index 36e79a4..a5fc252 100644 --- a/src/components/ExternalToolEditor/index.tsx +++ b/src/components/ExternalToolEditor/index.tsx @@ -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 (