Skip to content

Commit 6ba8320

Browse files
author
reco_luan
authored
Merge pull request #100 from IKangXu/develop
Develop
2 parents df4c63c + deef09c commit 6ba8320

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

components/NoteAbstractItem.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
<script>
2020
import PageInfo from './PageInfo'
21-
2221
export default {
2322
components: { PageInfo },
2423
props: ['item', 'currentPage', 'currentTag', 'hideAccessNumber']
@@ -27,7 +26,6 @@ export default {
2726

2827
<style lang="stylus" scoped>
2928
@require '../styles/recoConfig.styl'
30-
3129
.abstract-item
3230
position relative
3331
margin: 0 auto 20px;
@@ -83,10 +81,9 @@ export default {
8381
color $accentColor
8482
&:hover
8583
color $accentColor
86-
8784
@media (max-width: $MQMobile)
8885
.tags
8986
display block
9087
margin-top 1rem;
9188
margin-left: 0!important;
92-
</style>
89+
</style>

images/top.png

1006 Bytes
Loading

mixins/index.js

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,35 @@ export default {
77
return tagColorArr[index]
88
},
99
_filterPostData (posts, isTimeline) {
10-
const stickyArr = []
1110
posts = posts.filter(item => {
1211
const { title, frontmatter: { home, date, publish, sticky }} = item
13-
if (sticky) {
14-
stickyArr.unshift(item)
15-
return false
16-
}
1712
return isTimeline === true
1813
? !(home == true || title == undefined || date === undefined || publish === false)
1914
: !(home == true || title == undefined || publish === false)
2015
})
21-
this._sortstickyArr(stickyArr)
22-
return stickyArr.concat(posts)
23-
},
24-
_sortstickyArr (posts) {
25-
if (posts.length > 0) {
26-
posts.sort((a, b) => {
27-
return b.sticky - a.sticky
28-
})
29-
}
16+
return posts
3017
},
3118
_sortPostData (posts) {
3219
posts.sort((a, b) => {
33-
return this._getTimeNum(b) - this._getTimeNum(a)
20+
let aSticky = a.frontmatter.sticky, bSticky=b.frontmatter.sticky;
21+
if(aSticky && bSticky) {
22+
return aSticky == bSticky ? this._compareTime(a,b) : (aSticky - bSticky)
23+
} else if(aSticky && !bSticky) {
24+
return -1;
25+
} else if(!aSticky && bSticky){
26+
return 1;
27+
}
28+
return this._compareTime(a,b)
3429
})
3530
},
3631
// 获取时间的数字类型
3732
_getTimeNum (date) {
3833
return parseInt(new Date(date.frontmatter.date).getTime())
3934
},
35+
// 比对时间
36+
_compareTime(a, b) {
37+
return this._getTimeNum(b) - this._getTimeNum(a)
38+
},
4039
// 获取博客数据
4140
_getPostData () {
4241
return new Promise(resolve => {
@@ -51,9 +50,9 @@ export default {
5150
return [...allData, ...currnetData.pages]
5251
}, [])
5352

54-
_sortPostData(posts)
5553
posts = _filterPostData(posts)
56-
54+
_sortPostData(posts)
55+
5756
this.$themeConfig.posts = posts
5857
resolve(posts)
5958
}
@@ -77,4 +76,4 @@ export default {
7776
sessionStorage.setItem('currentPage', JSON.stringify({ page, path }))
7877
}
7978
}
80-
}
79+
}

0 commit comments

Comments
 (0)