Skip to content

Commit aa62ff6

Browse files
committed
Merge branch 'dev' into master
# Conflicts: # docs/.vuepress/dist/404.html # docs/.vuepress/dist/about/index.html # docs/.vuepress/dist/index.html # docs/.vuepress/dist/links/index.html # docs/.vuepress/dist/post/post1/index.html # docs/.vuepress/dist/post/post2/index.html # docs/.vuepress/dist/post/post3/index.html # docs/.vuepress/dist/post/post4/index.html # docs/.vuepress/dist/post/post5/index.html # docs/.vuepress/dist/post/post6/index.html # docs/.vuepress/dist/search/ECMAScript 6/index.html # docs/.vuepress/dist/search/Java/index.html # docs/.vuepress/dist/search/JavaScript/index.html # docs/.vuepress/dist/search/index.html # docs/.vuepress/dist/search/vue/index.html # docs/post/post2.md
2 parents 4fa09d4 + 1b347c1 commit aa62ff6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+12911
-562
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ yarn-error.log*
1414
*.ntvs*
1515
*.njsproj
1616
*.sln
17+

components/AllMixin.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

components/BackTop.vue

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@
1818
}
1919
},
2020
beforeMount() {
21-
this.$nextTick(() => {
22-
window.addEventListener('scroll', () => {
23-
if (this.$tool.getScrollOffset().top > 200) {
24-
!this.show && (this.show = true)
25-
} else {
26-
this.show && (this.show = false)
27-
}
28-
})
21+
window.addEventListener('scroll', () => {
22+
if (this.$tool.getScrollOffset().top > 200) {
23+
!this.show && (this.show = true)
24+
} else {
25+
this.show && (this.show = false)
26+
}
2927
})
3028
}
3129
}

components/Cards.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<el-row class="cards-container">
3-
<el-col :xs="24" :sm="12" :md="8" v-for="(item, index) in pages" :index="index">
3+
<el-col :xs="24" :sm="{span: 10, push: 2}" :md="{span: 8, push: 0}" v-for="(item, index) in pages" :index="index">
44
<div class="cards-item-wrapper">
55
<el-card class="cards-item" shadow="always" :body-style="{ padding: '0px' }">
66
<div class="cards-item-cover" :style="`background-image: url(${item.cover});`"></div>

components/Catalog.vue

Lines changed: 61 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<template>
22
<div class="catalog-container" v-show="show">
3-
<div class="catalog-content catalog-hide J_catalog-content" v-if="headers.length!==0">
3+
<div class="catalog-content catalog-hide J_catalogContent" v-if="headers.length!==0">
44
<ul>
55
<li v-for="(item, index) in headers" :key="index"
66
@click="clickHeaders(index)"
77
:class="`catalog-item-${item.level}`">
8-
{{item.title}}
8+
{{ item.title }}
99
</li>
1010
</ul>
1111
</div>
12-
<div class='catalog-open' v-if="this.$frontmatter.layout === 'Post'" @click="openAnchor">
12+
<div class='catalog-open' v-if="this.$frontmatter.layout === 'Post'" @click="openAnchor()">
1313
<i class="el-icon-s-operation"></i>
1414
</div>
1515
</div>
@@ -21,59 +21,79 @@
2121
data() {
2222
return {
2323
headers: [],
24-
heights: [],
25-
show: false
24+
titles: [],
25+
show: false,
2626
}
2727
},
2828
methods: {
2929
clickHeaders(index) {
30-
this.$tool.scrollTo(this.heights[index])
30+
const target = this.$tool.getPositionInPage(this.titles[index]).top
31+
const distance = this.$tool.getScrollOffset().top <= target ? 0 : 70
32+
this.$tool.scrollTo(target - distance)
3133
},
3234
openAnchor() {
33-
const catalog = document.getElementsByClassName('J_catalog-content')[0]
34-
this.$tool.triggerClass(catalog, 'catalog-hide')
35+
const catalog = document.querySelector('.J_catalogContent')
36+
this.$tool.toggleClass(catalog, 'catalog-hide')
3537
}
3638
},
3739
mounted() {
3840
// catalog item
3941
this.headers = this.$page.headers || []
42+
this.titles = document.querySelectorAll('.J_markdownContent h2, .J_markdownContent h3')
43+
44+
window.addEventListener('scroll', () => {
45+
this.show = this.$tool.getScrollOffset().top > 200;
46+
})
47+
4048
this.$nextTick(() => {
41-
// catalog hide or show
42-
window.addEventListener('scroll', () => {
43-
if (this.$tool.getScrollOffset().top > 200) {
44-
this.show = true
49+
const getScrollOffset = this.$tool.getScrollOffset
50+
const addClass = this.$tool.addClass
51+
const removeClass = this.$tool.removeClass
52+
const getPositionUp = (el) => {
53+
return this.$tool.getPositionInPage(el).top - 70
54+
}
55+
const getPositionDown = (el) => {
56+
return this.$tool.getPositionInPage(el).top
57+
}
58+
59+
const list = document.querySelectorAll('.J_catalogContent li')
60+
const arr = this.titles
61+
const len = this.titles.length
62+
let getPosition
63+
let before = Math.ceil(getScrollOffset().top)
64+
// catalog follows the page scroll
65+
window.addEventListener('scroll', this.$tool.throttle(() => {
66+
if (len === 0) {
67+
return
68+
}
69+
let scrollTop = Math.ceil(getScrollOffset().top)
70+
if (scrollTop < before) {
71+
getPosition = getPositionUp
72+
} else {
73+
getPosition = getPositionDown
74+
}
75+
before = scrollTop
76+
if (scrollTop <= getPosition(arr[0])) {
77+
addClass(list[0], 'catalog-item-active')
78+
list[0].scrollIntoView()
4579
} else {
46-
this.show = false
80+
removeClass(list[0], 'catalog-item-active')
4781
}
48-
})
49-
setTimeout(() => {
50-
// catalog follow scroll
51-
const getPositionInPage = this.$tool.getPositionInPage
52-
const hElements = document.querySelectorAll('.J_markdown-content h2,.J_markdown-content h3')
53-
;[].forEach.call(hElements, (item) => {
54-
this.heights.push(getPositionInPage(item).top - 70)
55-
})
56-
const list = document.querySelectorAll('.J_catalog-content li')
57-
const arr = this.heights
58-
const len = arr.length
59-
window.addEventListener('scroll', () => {
60-
const scrollTop = this.$tool.getScrollOffset().top
61-
for (let i = 0; i < len - 1; i++) {
62-
if (scrollTop >= arr[i] && scrollTop < arr[i + 1]) {
63-
this.$tool.addClass(list[i], 'catalog-item-active')
64-
list[i].scrollIntoView()
65-
} else {
66-
this.$tool.removeClass(list[i], 'catalog-item-active')
67-
}
68-
if (scrollTop >= arr[len - 1]) {
69-
this.$tool.addClass(list[len - 1], 'catalog-item-active')
70-
list[i].scrollIntoView()
71-
} else {
72-
this.$tool.removeClass(list[len - 1], 'catalog-item-active')
73-
}
82+
for (let i = 1; i < len - 1; i++) {
83+
if (scrollTop >= getPosition(arr[i]) && scrollTop < getPosition(arr[i + 1])) {
84+
addClass(list[i], 'catalog-item-active')
85+
list[i].scrollIntoView()
86+
} else {
87+
removeClass(list[i], 'catalog-item-active')
7488
}
75-
})
76-
}, 1000)
89+
}
90+
if (scrollTop >= getPosition(arr[len - 1])) {
91+
addClass(list[len - 1], 'catalog-item-active')
92+
list[len - 1].scrollIntoView()
93+
} else {
94+
removeClass(list[len - 1], 'catalog-item-active')
95+
}
96+
}, 100))
7797
})
7898
}
7999
}

components/Comment.vue

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
11
<template>
2-
<div class="comment-container J_comment-container"></div>
2+
<div class="comment-container" v-if="ifComment">
3+
<div class="comment-title">
4+
<i class="el-icon-s-comment" />
5+
Comment here, be cool~
6+
</div>
7+
<div class="J_comment" ></div>
8+
</div>
39
</template>
410

511
<script>
6-
import comment from 'valine'
7-
812
export default {
913
name: 'Comment',
1014
data() {
1115
return {
12-
appId: '',
13-
appKey: ''
16+
ifComment: true
1417
}
1518
},
16-
created() {
17-
this.appId = this.$themeConfig.comment[0]
18-
this.appKey = this.$themeConfig.comment[1]
19-
},
2019
mounted() {
21-
if (this.appId && this.appKey) {
22-
new comment({
23-
el: '.J_comment-container',
24-
appId: this.appId,
25-
appKey: this.appKey,
26-
enableQQ: true,
27-
placeholder: '昵称框填写 QQ,可获取头像、邮箱,快速评论~',
28-
pageSize: 1,
29-
path: window.location.pathname
30-
})
20+
const appId = this.$themeConfig.comment[0]
21+
const appKey = this.$themeConfig.comment[1]
22+
if (!appId || !appKey) {
23+
this.ifComment = false
3124
}
3225
}
3326
}

components/Foot.vue

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@
66
:key="index"
77
:href="item.url"
88
target="_blank">
9-
{{item.text}}
9+
{{ item.text }}
1010
</a>
1111
</div>
1212
<div class="foot-meta">
13-
<p>Copyright &copy; 2020 {{author}}</p>
13+
<p>Copyright &copy; 2020 {{ author }}</p>
1414
<p>
1515
Theme
1616
<a href="https://github.com/cadecode/vuepress-theme-2zh" target="_blank">2zh</a>
1717
powered by
18-
<a href="https://www.vuepress.cn/" target="_blank">vuepress</a>
18+
<a href="https://www.vuepress.cn/" target="_blank">VuePress</a>
1919
</p>
20-
<p>
21-
<a v-if="domain" :href="`${domain}/sitemap.xml`" target="_blank">Sitemap</a>
20+
<p :id="this.$route.path" v-if="ifVisitor" class="leancloud_visitors"
21+
:data-flag-title="this.$frontmatter.title">
22+
本页访问次数 <i class="leancloud-visitors-count">0</i>
2223
</p>
2324
</div>
2425
</div>
@@ -31,13 +32,31 @@
3132
return {
3233
author: '',
3334
links: [],
34-
domain: ''
35+
domain: '',
36+
ifVisitor: true
3537
}
3638
},
3739
created() {
3840
this.author = this.$themeConfig.author
3941
this.links = this.$themeConfig.links
4042
this.domain = this.$themeConfig.domain.trim().replace(/\/$/, '')
43+
},
44+
mounted() {
45+
const appId = this.$themeConfig.comment[0]
46+
const appKey = this.$themeConfig.comment[1]
47+
if (!appId || !appKey) {
48+
this.ifVisitor = false
49+
return
50+
}
51+
new this.$bus.valine({
52+
el: '.J_comment',
53+
appId,
54+
appKey,
55+
enableQQ: true,
56+
placeholder: '昵称框填写 QQ,可自动获取 QQ 名称以及头像、邮箱哦~',
57+
path: this.$route.path,
58+
visitor: true
59+
})
4160
}
4261
}
4362
</script>

components/GlobalMixin.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

components/Head.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="head-container" ref="head">
2+
<div class="head-container head-hide" ref="head">
33
<div class="head-content clearfix">
44
<div class="head-logo">
55
<a href="/">

components/Loading.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<template>
2+
<div class="loading-container">
3+
<div class="loading-box">
4+
<span>Loading</span>
5+
</div>
6+
</div>
7+
</template>
8+
9+
<script>
10+
export default {
11+
name: "Loading"
12+
}
13+
</script>

0 commit comments

Comments
 (0)