diff --git a/src/components/CodemirrorEditor/EditorHeader/index.vue b/src/components/CodemirrorEditor/EditorHeader/index.vue index c8de85f..c64249d 100644 --- a/src/components/CodemirrorEditor/EditorHeader/index.vue +++ b/src/components/CodemirrorEditor/EditorHeader/index.vue @@ -133,10 +133,9 @@ function copy() { window.getSelection()!.removeAllRanges() - if (copyMode.value === `html`) { - await copyContent(clipboardDiv.innerHTML) - } - else { + const temp = clipboardDiv.innerHTML + + if (copyMode.value === `txt`) { const range = document.createRange() range.setStartBefore(clipboardDiv.firstChild!) range.setEndAfter(clipboardDiv.lastChild!) @@ -151,6 +150,10 @@ function copy() { nextTick(() => toggleDark()) } + if (copyMode.value === `html`) { + await copyContent(temp) + } + // 输出提示 toast.success(copyMode.value === `html` ? `已复制 HTML 源码,请进行下一步操作。` : `已复制渲染后的文章到剪贴板,可直接到公众号后台粘贴。`)