From 6e8763ff754de508ac9e36b6bff6b6fd40bce4a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=A0=91?= Date: Thu, 14 Oct 2021 20:12:19 +0800 Subject: [PATCH] feat: export html page (#68) --- src/assets/scripts/util.js | 17 +++++++++++++++++ src/components/CodemirrorEditor/header.vue | 13 +++++++++++++ .../CodemirrorEditor/rightClickMenu.vue | 4 ++++ src/pages/index/view/CodemirrorEditor.vue | 9 +++++++++ 4 files changed, 43 insertions(+) diff --git a/src/assets/scripts/util.js b/src/assets/scripts/util.js index 9c2fb5f..43be7b7 100644 --- a/src/assets/scripts/util.js +++ b/src/assets/scripts/util.js @@ -235,6 +235,23 @@ export function downloadMD(doc) { document.body.removeChild(downLink); } +/** + * 导出 HTML 生成内容 + * @param {HTML生成内容} htmlStr + */ +export function exportHTML(htmlStr) { + const downLink = document.createElement('a') + + downLink.download = 'content.html'; + downLink.style.display = "none"; + let blob = new Blob([`${htmlStr}`]) + + downLink.href = URL.createObjectURL(blob); + document.body.appendChild(downLink); + downLink.click(); + document.body.removeChild(downLink); +} + /** * 生成列表字符串 * @param {*} data 对应内容集合 diff --git a/src/components/CodemirrorEditor/header.vue b/src/components/CodemirrorEditor/header.vue index 623c25e..0d47e75 100644 --- a/src/components/CodemirrorEditor/header.vue +++ b/src/components/CodemirrorEditor/header.vue @@ -22,6 +22,19 @@ @click="$emit('download')" > + + + +