From d31dd100d65f421a9fbcd5d7033acc5c0577ad26 Mon Sep 17 00:00:00 2001 From: xlsea Date: Tue, 25 Feb 2025 14:25:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(1.4.0-beta1):=20=E4=BF=AE=E5=A4=8D=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=BC=96=E8=BE=91=E5=99=A8=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/code-mirror.vue | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/common/code-mirror.vue b/src/components/common/code-mirror.vue index 18bfc07..a9c219c 100644 --- a/src/components/common/code-mirror.vue +++ b/src/components/common/code-mirror.vue @@ -106,14 +106,16 @@ const theme = computed(() => { watch( () => nodeExpression.value, - val => { - let value = val; + () => { if (props.lang === 'json') { try { - value = JSON.stringify(JSON.parse(val)); + const obj = JSON.parse(nodeExpression.value); + if (typeof obj === 'object') { + nodeExpression.value = JSON.stringify(obj); + } } catch {} } - emit('update:modelValue', value); + emit('update:modelValue', nodeExpression.value); } );