From 51e4c85019ecde598684c851446159f4baf6a24d Mon Sep 17 00:00:00 2001 From: jmal Date: Thu, 12 Mar 2020 18:03:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9article=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 2 +- src/views/home/index.vue | 2 +- src/views/home/mobile/index.vue | 2 +- src/views/public/article/index.vue | 16 ++++++++++++---- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index cc3478f..c61be34 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -126,7 +126,7 @@ export const constantRoutes = [ }, { - path: '/public/article', + path: '/public/articles/article', component: Layout, children: [ { diff --git a/src/views/home/index.vue b/src/views/home/index.vue index 5779d37..c374c50 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -1422,7 +1422,7 @@ export default { if(row.contentType.includes('text')){ // let routeData = this.$router.resolve({path: '/public/p',query: {mark: row.id}}) // window.open(routeData.href, '_blank'); - this.$router.push(`/public/article?mark=${row.id}`) + this.$router.push(`/public/articles/article?mark=${row.id}`) }else{ // 打开文件 const fileIds = [row.id] diff --git a/src/views/home/mobile/index.vue b/src/views/home/mobile/index.vue index 759d2f0..4fd1c7f 100644 --- a/src/views/home/mobile/index.vue +++ b/src/views/home/mobile/index.vue @@ -769,7 +769,7 @@ if(row.contentType.includes('text')){ // let routeData = this.$router.resolve({path: '/public/p',query: {mark: row.id}}) // window.open(routeData.href, '_blank'); - this.$router.push(`/public/article?mark=${row.id}`) + this.$router.push(`/public/articles/article?mark=${row.id}`) }else{ // 打开文件 const fileIds = [row.id] diff --git a/src/views/public/article/index.vue b/src/views/public/article/index.vue index d6ee761..452b923 100644 --- a/src/views/public/article/index.vue +++ b/src/views/public/article/index.vue @@ -91,7 +91,9 @@ a = a.splice(a.length/2,a.length) for (let i = 0; i < a.length; i++) { a[i] = a[i].replace(/id="/g, 'href="#') - if (a[i].indexOf('h2') != -1) { + if (a[i].indexOf('h1') === 1) { + a[i] = '
  • ' + a[i].replace(/

    |<\/h1>/g, '') + '

  • ' + }else if (a[i].indexOf('h2') !== -1) { a[i] = '
  • ' + a[i].replace(/

    |<\/h2>/g, '') + '

  • ' } else { a[i] = '
  • ' + a[i].replace(/

    |<\/h1>/g, '') + '

  • ' @@ -115,9 +117,15 @@ let $root = $('html, body'); $('.j-titleList li').on("click", function () { + console.log(typeof($(this).attr("first"))!=="undefined") + let top = 20 + if (typeof($(this).attr("first"))!=="undefined") { + // 点击第一个目录 + top = 50 + } $root.animate({ - scrollTop: $($.attr(this.querySelector("a"), 'href')).offset().top - 20 - }, 400); + scrollTop: $($.attr(this.querySelector("a"), 'href')).offset().top - top + }, 400) return false }); } @@ -126,7 +134,7 @@ setTimeout(function () { addCodeBtn(); _this.isLoading = false - },100) + },150) })