From 362daa8808b6fe13e9da283a86158b5867848c9c Mon Sep 17 00:00:00 2001 From: jmal Date: Tue, 10 Mar 2020 23:21:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=BF=E6=8D=A2markdown=E4=B8=AD=E5=9B=BE?= =?UTF-8?q?=E7=89=87URL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/public/article/index.vue | 37 ++++++++++++++++++------------ 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/views/public/article/index.vue b/src/views/public/article/index.vue index 58c89eb..facf8ab 100644 --- a/src/views/public/article/index.vue +++ b/src/views/public/article/index.vue @@ -64,12 +64,22 @@ }).then((res) => { this.pageTitle = res.data.name this.content = res.data.contentText + this.content.r + let n = this.content.replace(/(?:!\[(.*?)\]\((.*?)\))/,(matched,capture1,capture2,capture3,capture4)=>{ + console.log("matched:"+matched,"capture1:"+capture1,"capture2:"+capture2,"capture3:"+capture3); + console.log(capture3) + if(!capture2.includes("/file/public")){ + return "/file/public/view?relativePath="+path + capture2 +"&userId="+userId; + } + }) + console.log(n); + // console.log(this.content.match(/(?:!\[(.*?)\]\((.*?)\))/)); let path = res.data.path let userId = res.data.userId setTimeout(function () { // 刷新界面 回到上次滚动条的位置 if (document.cookie.match(/scrollTop=([^;]+)(;|$)/) != null) { - var arr = document.cookie.match(/scrollTop=([^;]+)(;|$)/); //cookies中不为空,则读取滚动条位置 + const arr = document.cookie.match(/scrollTop=([^;]+)(;|$)/); //cookies中不为空,则读取滚动条位置 document.documentElement.scrollTop = parseInt(arr[1]); document.body.scrollTop = parseInt(arr[1]); } @@ -82,20 +92,17 @@ this.pageTitle = hTag.innerText } - setTimeout(function () { - let images = document.querySelector(".el-main").getElementsByTagName("img"); - console.log(images) - // let images = $('.el-main').find("img"); - // console.log(images[0].getAttr("src")) - // const oldSrc = images[i].attr("src") - // for (let i = 0; i < images.length/2; i++) { - // if(!oldSrc.startsWith("/file/public")){ - // const newPath = "/file/public/view?relativePath="+path + oldSrc +"&userId="+userId; - // console.log(newPath) - // images[i].attr("src",newPath) - // } - // } - }) + // setTimeout(function () { + // let images = document.querySelector(".el-main").getElementsByTagName("img"); + // console.log(images.item(1).getAttribute('src')) + // for (let i = 0; i < images.length/2; i++) { + // const oldSrc = images.item(i).getAttribute('src') + // if(!oldSrc.includes("/file/public")){ + // const newPath = "/file/public/view?relativePath="+path + oldSrc +"&userId="+userId; + // images.item(i).src = newPath + // } + // } + // },0) let a = $('.el-main').html().match(/|/g); if(a && a.length >0 ){