|
| 1 | +<template> |
| 2 | + <div class="tag-wrapper" :class="recoShow ?'reco-show' : 'reco-hide'"> |
| 3 | + <!-- 公共布局 --> |
| 4 | + <Common :sidebar="false" :isComment="false"> |
| 5 | + <!-- 标签集合 --> |
| 6 | + <TagList class="tags" :currentTag="$currentTags.key" @getCurrentTag="tagClick"></TagList> |
| 7 | + |
| 8 | + <!-- 博客列表 --> |
| 9 | + <note-abstract |
| 10 | + class="list" |
| 11 | + :data="posts" |
| 12 | + :currentPage="currentPage" |
| 13 | + @currentTag="$currentTags.key"></note-abstract> |
| 14 | + |
| 15 | + <!-- 分页 --> |
| 16 | + <pagation |
| 17 | + class="pagation" |
| 18 | + :total="posts.length" |
| 19 | + :currentPage="currentPage" |
| 20 | + @getCurrentPage="getCurrentPage"></pagation> |
| 21 | + </Common> |
| 22 | + </div> |
| 23 | +</template> |
| 24 | + |
| 25 | +<script> |
| 26 | +import Common from '@theme/components/Common.vue' |
| 27 | +import NoteAbstract from '@theme/components/NoteAbstract.vue' |
| 28 | +import TagList from '@theme/components/TagList.vue' |
| 29 | +import mixin from '@theme/mixins/index.js' |
| 30 | +
|
| 31 | +export default { |
| 32 | + mixins: [mixin], |
| 33 | + components: { Common, NoteAbstract, TagList }, |
| 34 | +
|
| 35 | + data () { |
| 36 | + return { |
| 37 | + // 当前页码 |
| 38 | + currentPage: 1, |
| 39 | + recoShow: false, |
| 40 | + currentTag: '全部', |
| 41 | + } |
| 42 | + }, |
| 43 | +
|
| 44 | + computed: { |
| 45 | + // 时间降序后的博客列表 |
| 46 | + posts () { |
| 47 | + let posts = this.$currentTags.pages |
| 48 | + posts = this._filterPostData(posts) |
| 49 | + this._sortPostData(posts) |
| 50 | + this._setPage(1) |
| 51 | + return posts |
| 52 | + }, |
| 53 | + }, |
| 54 | +
|
| 55 | + mounted () { |
| 56 | + this.recoShow = true |
| 57 | + }, |
| 58 | +
|
| 59 | + methods: { |
| 60 | + // 获取当前tag |
| 61 | + getCurrentTag (tag) { |
| 62 | + this.$emit('currentTag', tag) |
| 63 | + }, |
| 64 | + tagClick (tagInfo) { |
| 65 | + this.$router.push({path: tagInfo.path}) |
| 66 | + }, |
| 67 | + // 获取当前页码 |
| 68 | + getCurrentPage (page) { |
| 69 | + this._setPage(page) |
| 70 | + setTimeout(() => { |
| 71 | + window.scrollTo(0, 0) |
| 72 | + }, 100) |
| 73 | + }, |
| 74 | + _setPage (page) { |
| 75 | + this.currentPage = page |
| 76 | + this.$page.currentPage = page |
| 77 | + }, |
| 78 | + } |
| 79 | +} |
| 80 | +</script> |
| 81 | + |
| 82 | +<style src="../styles/theme.styl" lang="stylus"></style> |
| 83 | + |
| 84 | +<style lang="stylus" scoped> |
| 85 | +@require '../styles/recoConfig.styl' |
| 86 | +@require '../styles/loadMixin.styl' |
| 87 | +.tag-wrapper |
| 88 | + max-width: 740px; |
| 89 | + margin: 0 auto; |
| 90 | + padding: 4.6rem 2.5rem 0; |
| 91 | + &.reco-hide { |
| 92 | + .tags, .list, .pagation { |
| 93 | + load-start() |
| 94 | + } |
| 95 | + } |
| 96 | + &.reco-show { |
| 97 | + .tags { |
| 98 | + load-end(0.08s) |
| 99 | + } |
| 100 | + .list { |
| 101 | + load-end(0.16s) |
| 102 | + } |
| 103 | + .pagation { |
| 104 | + load-end(0.24s) |
| 105 | + } |
| 106 | + } |
| 107 | +
|
| 108 | +@media (max-width: $MQMobile) |
| 109 | + .tag-wrapper |
| 110 | + padding: 4.6rem 1rem 0; |
| 111 | +</style> |
0 commit comments