From fa9ada233455b0af9380e1709e7d61c761e008a2 Mon Sep 17 00:00:00 2001 From: 2910410219 <2910410219@qq.com> Date: Thu, 16 Jul 2026 17:32:20 +0800 Subject: [PATCH] =?UTF-8?q?fix(json-schema-editor):=20=E6=A0=B9=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E8=BE=93=E5=87=BA=E6=97=B6=E5=8E=BB=E9=99=A4=20{=20ty?= =?UTF-8?q?pe,=20attrs=20}=20=E5=8C=85=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 最外层根 object 不应该套 { type, attrs } 包装, 应直接输出子字段组成的原始对象。 - nodeToValue 中增加根节点判断:node === rootNode.value 时直接返回 rawValue - 非根节点保持原有 { type, attrs/value, ...config } 格式不变 --- src/components/json-schema-editor/index.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/json-schema-editor/index.vue b/src/components/json-schema-editor/index.vue index 5c63c10..3fb477f 100644 --- a/src/components/json-schema-editor/index.vue +++ b/src/components/json-schema-editor/index.vue @@ -193,6 +193,9 @@ function nodeToValue(node: JsonNodeData): any { else if (node.type === 'boolean') rawValue = node.primitiveValue === true || node.primitiveValue === 'true'; else rawValue = String(node.primitiveValue); + // 最外层根 object 不套 { type, attrs },直接返回原始对象 + if (node === rootNode.value) return rawValue; + // 容器类型(object/array)始终输出 { type, attrs, ...config } if (node.type === 'object' || node.type === 'array') { const result: Record = { type: node.type, attrs: rawValue }; @@ -205,10 +208,10 @@ function nodeToValue(node: JsonNodeData): any { // 标量类型也始终输出 { type, value, ...config } const result: Record = { type: node.type, value: rawValue }; if (node.config && hasAnyConfig(node)) { - Object.assign(result, node.config); + Object.assign(result, node.config); + } + return result; } - return result; -} function defaultFormType(jsonType: string): string { const m: Record = { string: 'string', number: 'number', boolean: 'switch' };