File tree Expand file tree Collapse file tree 4 files changed +31
-26
lines changed
Expand file tree Collapse file tree 4 files changed +31
-26
lines changed Original file line number Diff line number Diff line change @@ -79,8 +79,10 @@ import Sidebar from '@theme/components/Sidebar.vue'
7979import { resolveSidebarItems } from ' ../util'
8080import Password from ' @theme/components/Password'
8181import { setTimeout } from ' timers'
82+ import mixin from ' @theme/mixins/index.js'
8283
8384export default {
85+ mixins: [mixin],
8486 components: { Sidebar, Navbar, Password },
8587
8688 props: {
@@ -167,6 +169,10 @@ export default {
167169 }
168170 },
169171
172+ created () {
173+ this .getPostData ()
174+ },
175+
170176 mounted () {
171177 this .$router .afterEach (() => {
172178 this .isSidebarOpen = false
@@ -227,6 +233,23 @@ export default {
227233 this .firstLoad = false
228234 if (sessionStorage .getItem (' firstLoad' ) == undefined ) sessionStorage .setItem (' firstLoad' , false )
229235 }, time)
236+ },
237+ getPostData () {
238+ if (! this .$themeConfig .posts ) {
239+ const {
240+ $categories: { list: articles },
241+ _filterPostData ,
242+ _sortPostData
243+ } = this
244+
245+ let posts = articles .reduce ((allData , currnetData ) => {
246+ return [... allData, ... currnetData .pages ]
247+ }, [])
248+ posts = _filterPostData (posts)
249+ _sortPostData (posts)
250+
251+ this .$themeConfig .posts = posts
252+ }
230253 }
231254 },
232255
Original file line number Diff line number Diff line change 1111 <div class =" blog-list" >
1212 <!-- 博客列表 -->
1313 <note-abstract
14- :data =" posts"
14+ :data =" $themeConfig. posts"
1515 :hideAccessNumber =" true"
1616 :currentPage =" currentPage" ></note-abstract >
1717 <!-- 分页 -->
1818 <pagation
1919 class =" pagation"
20- :total =" posts.length"
20+ :total =" $themeConfig. posts.length"
2121 :currentPage =" currentPage"
2222 @getCurrentPage =" getCurrentPage" />
2323 </div >
2626 <h3 class =" name" v-if =" $themeConfig.author || $site.title" >{{ $themeConfig.author || $site.title }}</h3 >
2727 <div class =" num" >
2828 <div >
29- <h3 >{{getPagesLength }}</h3 >
29+ <h3 >{{$themeConfig.posts.length }}</h3 >
3030 <h6 >文章</h6 >
3131 </div >
3232 <div >
@@ -73,24 +73,6 @@ export default {
7373 }
7474 },
7575 computed: {
76- // 时间降序后的博客列表
77- posts () {
78- const {
79- $site: { pages },
80- _filterPostData ,
81- _sortPostData
82- } = this
83-
84- let posts = pages
85- posts = _filterPostData (posts)
86- _sortPostData (posts)
87-
88- return posts
89- },
90- // 分类信息
91- getPagesLength () {
92- return this .posts .length
93- },
9476 actionLink () {
9577 const {
9678 actionLink: link ,
Original file line number Diff line number Diff line change 11<template >
22 <div class =" tags" >
33 <span
4- v-for =" (item, index) in $ tags.list "
4+ v-for =" (item, index) in tags"
55 :key =" index"
66 :class =" {'active': item.name == currentTag}"
77 :style =" { 'backgroundColor': _tagColor() }"
@@ -20,9 +20,9 @@ export default {
2020 default: ' '
2121 }
2222 },
23- data () {
24- return {
25- tags : [ ]
23+ computed : {
24+ tags () {
25+ return [{ name : ' 全部 ' }, ... this . $tags . list ]
2626 }
2727 },
2828 methods: {
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ export default {
4545 if (currentTag !== ' 全部' ) {
4646 posts = this .$tags .map [currentTag].pages
4747 } else {
48- posts = this .$site . pages
48+ posts = this .$themeConfig . posts
4949 }
5050
5151 posts = this ._filterPostData (posts)
You can’t perform that action at this time.
0 commit comments