From bfdaf2b244dfe7387cac5b399a84ccd614201e73 Mon Sep 17 00:00:00 2001 From: roymondchen Date: Thu, 18 Jun 2026 17:28:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(playground):=20=E8=B0=83=E6=95=B4=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E6=97=B6=E5=BA=8F=E9=81=BF=E5=85=8D=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E6=81=A2=E5=A4=8D=E8=A2=AB=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将本地 magicDSL 的恢复逻辑移动到 restoreHistory 之后,避免页面初始化时覆盖已恢复的历史状态。 Co-authored-by: Cursor --- playground/src/pages/Editor.vue | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/playground/src/pages/Editor.vue b/playground/src/pages/Editor.vue index 634a4ee3..44541be2 100644 --- a/playground/src/pages/Editor.vue +++ b/playground/src/pages/Editor.vue @@ -105,19 +105,6 @@ const save = () => { const { menu, deviceGroup, iframe, previewVisible } = useEditorMenu(value, save); -try { - // eslint-disable-next-line no-eval - const magicDSL = eval(`(${localStorage.getItem('magicDSL')})`); - if (!magicDSL) { - save(); - } else { - value.value = magicDSL; - } -} catch (e) { - console.error(e); - save(); -} - editorService.usePlugin({ beforeDoAdd: (config: MNode, parent: MContainer) => { if (config.type === 'overlay') { @@ -174,7 +161,20 @@ editorService.on('root-change', rootChangeHandler); onMounted(async () => { await restoreHistory(); - value.value = dsl; + try { + // eslint-disable-next-line no-eval + const magicDSL = eval(`(${localStorage.getItem('magicDSL')})`); + if (!magicDSL) { + value.value = dsl; + save(); + } else { + value.value = magicDSL; + } + } catch (e) { + console.error(e); + save(); + } + historyService.on('change', schedulePersist); historyService.on('code-block-history-change', schedulePersist); historyService.on('data-source-history-change', schedulePersist);