Skip to content

Commit 18596d1

Browse files
author
reco_luan
committed
fix: some style error
1 parent 6ba8320 commit 18596d1

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

layouts/Category.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ export default {
5454
// 时间降序后的博客列表
5555
posts () {
5656
let posts = this.$currentCategories.pages
57-
this._sortPostData(posts)
5857
posts = this._filterPostData(posts)
58+
this._sortPostData(posts)
5959
return posts
6060
},
6161
// 标题只显示分类名称

layouts/Tag.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ export default {
4545
// 时间降序后的博客列表
4646
posts () {
4747
let posts = this.$currentTags.pages
48-
this._sortPostData(posts)
4948
posts = this._filterPostData(posts)
49+
this._sortPostData(posts)
5050
return posts
5151
}
5252
},

mixins/index.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
export default {
22
methods: {
33
_tagColor () {
4-
// 红、蓝、绿、橙、灰
54
const tagColorArr = ['#e15b64', '#f47e60', '#f8b26a', '#abbd81', '#849b87', '#e15b64', '#f47e60', '#f8b26a', '#f26d6d', '#67cc86', '#fb9b5f', '#3498db']
65
const index = Math.floor(Math.random() * tagColorArr.length)
76
return tagColorArr[index]
87
},
98
_filterPostData (posts, isTimeline) {
109
posts = posts.filter(item => {
11-
const { title, frontmatter: { home, date, publish, sticky }} = item
10+
const { title, frontmatter: { home, date, publish }} = item
1211
return isTimeline === true
1312
? !(home == true || title == undefined || date === undefined || publish === false)
1413
: !(home == true || title == undefined || publish === false)
@@ -17,23 +16,24 @@ export default {
1716
},
1817
_sortPostData (posts) {
1918
posts.sort((a, b) => {
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;
19+
const aSticky = a.frontmatter.sticky
20+
const 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
2727
}
28-
return this._compareTime(a,b)
28+
return this._compareTime(a, b)
2929
})
3030
},
3131
// 获取时间的数字类型
3232
_getTimeNum (date) {
3333
return parseInt(new Date(date.frontmatter.date).getTime())
3434
},
3535
// 比对时间
36-
_compareTime(a, b) {
36+
_compareTime (a, b) {
3737
return this._getTimeNum(b) - this._getTimeNum(a)
3838
},
3939
// 获取博客数据
@@ -52,7 +52,7 @@ export default {
5252

5353
posts = _filterPostData(posts)
5454
_sortPostData(posts)
55-
55+
5656
this.$themeConfig.posts = posts
5757
resolve(posts)
5858
}

0 commit comments

Comments
 (0)