From 0238d8fa8f54ad848a5f3578958492bc1d300426 Mon Sep 17 00:00:00 2001 From: DLLCNX Date: Thu, 3 Aug 2023 21:29:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=85=B6=E4=BB=96=E7=BD=91?= =?UTF-8?q?=E7=AB=99=E5=A4=8D=E5=88=B6=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 12 +++ src/assets/example/markdown.md | 24 ++++- .../CodemirrorEditor/EditorHeader/index.vue | 92 +++++++++++++++++-- 3 files changed, 120 insertions(+), 8 deletions(-) diff --git a/public/index.html b/public/index.html index eb45cc9..f060e3c 100644 --- a/public/index.html +++ b/public/index.html @@ -1,3 +1,14 @@ + @@ -29,6 +40,7 @@ href="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/gh/wechatsync/article-syncjs@latest/dist/styles.css" /> + diff --git a/src/assets/example/markdown.md b/src/assets/example/markdown.md index 524881b..59e12f6 100644 --- a/src/assets/example/markdown.md +++ b/src/assets/example/markdown.md @@ -1 +1,23 @@ -# sdfdsf \ No newline at end of file +# 示例文章:xxx + + +## 一、标题 + +### 1.1 一级标题 + + +## 二、段落 + + + + +## 三、字体 + + + + +## 四、欢迎访问 + +
+ +
diff --git a/src/components/CodemirrorEditor/EditorHeader/index.vue b/src/components/CodemirrorEditor/EditorHeader/index.vue index 58b31d5..dcafde8 100644 --- a/src/components/CodemirrorEditor/EditorHeader/index.vue +++ b/src/components/CodemirrorEditor/EditorHeader/index.vue @@ -137,7 +137,7 @@ - + + - 复制 + 复制到公众号 - + + + 复制到其它 + + + + {{ item.title }} + + + { + window.open(`https://mp.weixin.qq.com`, `_blank`) + }, 2000) }, 350) }, + copyMd(url) { + // 输出提示 + this.$notify({ + showClose: true, + message: `已复制渲染后的文章到剪贴板,2秒后将跳转至对应网站`, + offset: 80, + duration: 1600, + type: `success`, + }) + setTimeout(() => { + url && window.open(url, `_blank`) + }, 2000) + }, // 自定义CSS样式 async customStyle() { this.$emit(`showCssEditor`) @@ -410,6 +461,16 @@ export default { this.showResetConfirm = false this.editor.focus() }, + handleClick(e) { + let url = this.commands.filter((item) => item.key === e)[0].url + switch (e) { + case `wechat`: + this.copy(url) + break + default: + this.copyMd(url) + } + }, ...mapActions(useStore, [ `setCurrentColor`, `setCiteStatus`, @@ -420,6 +481,7 @@ export default { `setCurrentCodeTheme`, `setWxRendererOptions`, `setIsMacCodeBlock`, + `getDoc`, ]), }, mounted() { @@ -432,7 +494,9 @@ export default { const fileInput = this.$refs.fileInput fileInput.onchange = () => { + debugger const file = fileInput.files[0] + debugger if (file == null) { return } @@ -442,6 +506,20 @@ export default { this.$emit(`import-md`, read.result) } } + + var clipboard = new ClipboardJS(`#copyButton`, { + text: () => { + return this.editor.getValue() + }, + }) + + clipboard.on(`success`, (e) => { + console.log(`复制成功`) + }) + + clipboard.on(`error`, (e) => { + console.log(`复制失败`) + }) }, }