From 679e5f42877471a6c505efbb506a64c19f05a7f3 Mon Sep 17 00:00:00 2001 From: wangchengming <15110151257@163.com> Date: Sun, 20 Jul 2025 13:15:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/TEditor/index.vue | 50 +++++---- src/views/databaseLibary/components/card.vue | 3 +- .../databaseLibary/components/libaryForm.vue | 105 ++++++++++++------ .../components/myFileUpload.vue | 1 + 4 files changed, 98 insertions(+), 61 deletions(-) diff --git a/src/components/TEditor/index.vue b/src/components/TEditor/index.vue index 7bf39eb..810c5a5 100644 --- a/src/components/TEditor/index.vue +++ b/src/components/TEditor/index.vue @@ -96,7 +96,7 @@ const props = defineProps({ }); const loading = ref(false); const tinymceId = ref( - "vue-tinymce-" + +new Date() + ((Math.random() * 1000).toFixed(0) + "") + "vue-tinymce-" + +new Date() + ((Math.random() * 1000).toFixed(0) + "") ); const baseUrl = import.meta.env.VITE_APP_BASE_API @@ -217,8 +217,10 @@ const init = reactive({ // 设置初始化内容(初始化结束后执行) init_instance_callback: function (editor) { console.log('初始化内容', props.value) - editor.setContent(props.value); // 设置默认文本内容 - emits('update:modelValue', editor.getContent()) //更新 + if (props.value) { + editor.setContent(props.value); // 设置默认文本内容 + emits('update:modelValue', editor.getContent()) //更新 + } // 设置高度 editor.getContainer().setAttribute("style", `height: ${props.height}px;`); }, @@ -234,19 +236,19 @@ const myValue = computed({ }, }); - + // 监听富文本中的数据变化 -watch( - () => myValue.value, - () => { - emits( - "setHtml", - tinymce.activeEditor.getContent({ format: "text" }), - myValue.value - ); - } -); +// watch( +// () => myValue.value, +// () => { +// emits( +// "setHtml", +// tinymce.activeEditor.getContent({ format: "text" }), +// myValue.value +// ); +// } +// ); // 设置编辑器只读模式 watch( @@ -277,13 +279,13 @@ window.onresize = function temp() { }; // 设置值 -const handleSetContent = (content) => { +const handleSetContent = (content) => { tinymce.activeEditor.setContent(content); }; // 获取值 const handleGetContent = () => { - return tinymce.activeEditor.getContent(); + return tinymce.activeEditor.getContent(); }; const updateModelValue = (val) => { @@ -305,14 +307,14 @@ const updateModelValue = (val) => { }) } const checkEmptyContent = (editor) => { - const plainText = editor.getContent({ format: 'text' }).trim() - const htmlContent = editor.getContent() - - // 检测常见空内容情况 - return plainText === '' || - htmlContent === '' || - htmlContent === '
' + const plainText = editor.getContent({ format: 'text' }).trim() + const htmlContent = editor.getContent() + + // 检测常见空内容情况 + return plainText === '' || + htmlContent === '' || + htmlContent === '
' } diff --git a/src/views/databaseLibary/components/card.vue b/src/views/databaseLibary/components/card.vue index 64f1b52..295698d 100644 --- a/src/views/databaseLibary/components/card.vue +++ b/src/views/databaseLibary/components/card.vue @@ -12,7 +12,7 @@