From 8e56999f749723999496f80a095f2f078004e59d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=9D=A8?= <1711467488@qq.com> Date: Sat, 24 Feb 2018 17:22:05 +0800 Subject: [PATCH] no message Former-commit-id: 54128cef75768f9e96894cee70ab6d664f9c1f55 Former-commit-id: 58f0cef57b7ac8468c36f06c99016b774f528a93 Former-commit-id: bb87602f15c3cc6f996e0b761014b84b36a9c0e4 --- src/components/core/Markdown/index.vue | 16 ++-------------- src/components/core/Markdown/plugin/baidupan.js | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/components/core/Markdown/index.vue b/src/components/core/Markdown/index.vue index 20fe32bc..73aa8020 100644 --- a/src/components/core/Markdown/index.vue +++ b/src/components/core/Markdown/index.vue @@ -3,6 +3,7 @@
正在加载
+
@@ -67,20 +68,7 @@ export default { marked (data) { const renderer = new marked.Renderer() renderer.blockquote = (quote) => { - bandupan().then(() => { - console.log('----') - }) - const _quote = quote.replace(/<[^<>]+>/g, '').trim() - const bdShareUrl = /^https:\/\/pan\.baidu\.com\/s\/[a-z0-9]+$/i - const bdShareUrlPwd = /^链接: https:\/\/pan\.baidu\.com\/s\/[a-z0-9]+ 密码: [a-z0-9]{4}$/i - if (bdShareUrl.test(_quote)) { - return `
${_quote}
` - } else if (bdShareUrlPwd.test(_quote)) { - const url = _quote.match(/https:\/\/pan\.baidu\.com\/s\/[a-z0-9]+/i) - const pwd = _quote.match(/[a-z0-9]{4}$/i) - return `
${url[0]} - ${pwd[0]}
` - } - return `
${quote}
` + return bandupan(quote) || `
${quote}
` } return marked(data, { ...this.highlight ? {highlight: (code) => highlight.highlightAuto(code).value} : {}, diff --git a/src/components/core/Markdown/plugin/baidupan.js b/src/components/core/Markdown/plugin/baidupan.js index fb450bc3..4a328a8c 100644 --- a/src/components/core/Markdown/plugin/baidupan.js +++ b/src/components/core/Markdown/plugin/baidupan.js @@ -1,5 +1,14 @@ export default (quote) => { - return new Promise((resolve, reject) => { - resolve() - }) + const _quote = quote.replace(/<[^<>]+>/g, '').trim() + const bdShareUrl = /^https:\/\/pan\.baidu\.com\/s\/[a-z0-9]+$/i + const bdShareUrlPwd = /^链接: https:\/\/pan\.baidu\.com\/s\/[a-z0-9]+ 密码: [a-z0-9]{4}$/i + if (bdShareUrl.test(_quote)) { + return `
${_quote}
` + } else if (bdShareUrlPwd.test(_quote)) { + const url = _quote.match(/https:\/\/pan\.baidu\.com\/s\/[a-z0-9]+/i) + const pwd = _quote.match(/[a-z0-9]{4}$/i) + return `
${url[0]} - ${pwd[0]}
` + } else { + return false + } }