From c35246e2cc90b632bc0f7292a71acb476252c5c1 Mon Sep 17 00:00:00 2001 From: gpu Date: Wed, 4 Feb 2026 01:42:52 +0800 Subject: [PATCH] 21 --- .../danye/components/DanyeFormDialog.vue | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/server/HoneyBox/src/HoneyBox.Admin/admin-web/src/views/business/danye/components/DanyeFormDialog.vue b/server/HoneyBox/src/HoneyBox.Admin/admin-web/src/views/business/danye/components/DanyeFormDialog.vue index 876b2fac..83b3257a 100644 --- a/server/HoneyBox/src/HoneyBox.Admin/admin-web/src/views/business/danye/components/DanyeFormDialog.vue +++ b/server/HoneyBox/src/HoneyBox.Admin/admin-web/src/views/business/danye/components/DanyeFormDialog.vue @@ -164,9 +164,17 @@ const handleCreated = (editor: IDomEditor) => { editorRef.value = editor // 如果有内容,设置到编辑器 + // 使用 nextTick 确保编辑器完全初始化后再设置内容 if (formData.content) { console.log('[DanyeFormDialog] Setting initial content to editor:', formData.content.substring(0, 100)) - editor.setHtml(formData.content) + // 先清空编辑器,再设置新内容,避免 operations 历史记录冲突 + editor.clear() + // 使用 setTimeout 确保 clear 操作完成后再设置内容 + setTimeout(() => { + if (!editor.isDestroyed) { + editor.setHtml(formData.content) + } + }, 0) } } @@ -179,6 +187,16 @@ watch(() => props.modelValue, (visible) => { console.log('[DanyeFormDialog] formData.content set to:', formData.content.substring(0, 100)) console.log('[DanyeFormDialog] editorRef.value:', editorRef.value) console.log('[DanyeFormDialog] editorRef.value?.isDestroyed:', editorRef.value?.isDestroyed) + + // 如果编辑器已存在且未销毁,直接设置内容 + if (editorRef.value && !editorRef.value.isDestroyed) { + editorRef.value.clear() + setTimeout(() => { + if (editorRef.value && !editorRef.value.isDestroyed) { + editorRef.value.setHtml(formData.content) + } + }, 0) + } } })