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 + } }