2019-06-18 18:41:09 +08:00
|
|
|
|
<template>
|
|
|
|
|
<div class="home-blog" :class="recoShow?'reco-show': 'reco-hide'">
|
2019-10-09 09:45:19 +08:00
|
|
|
|
<div class="hero" :style="{background: `url(${$frontmatter.bgImage ? $withBase($frontmatter.bgImage) : require('../images/home-bg.jpg')}) center/cover no-repeat`, ...bgImageStyle}">
|
2019-11-01 19:32:52 +08:00
|
|
|
|
<h1>{{ $frontmatter.heroText || $title || '午后南杂' }}</h1>
|
2019-06-18 18:41:09 +08:00
|
|
|
|
|
2019-10-27 20:34:46 +08:00
|
|
|
|
<p class="description">{{ $description || 'Welcome to your vuePress-theme-reco site' }}</p>
|
2019-07-20 19:00:36 +08:00
|
|
|
|
<p class="huawei" v-if="$themeConfig.huawei === true"><i class="iconfont reco-huawei" style="color: #fc2d38"></i> 华为,为中华而为之!</p>
|
2019-06-18 18:41:09 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
2019-07-06 02:00:12 +08:00
|
|
|
|
<div class="home-blog-wrapper">
|
2019-10-08 22:57:03 +08:00
|
|
|
|
<div class="blog-list">
|
2019-10-04 22:35:38 +08:00
|
|
|
|
<!-- 博客列表 -->
|
|
|
|
|
<note-abstract
|
|
|
|
|
:data="posts"
|
2019-10-16 15:06:20 +08:00
|
|
|
|
:hideAccessNumber="true"
|
2019-10-04 22:35:38 +08:00
|
|
|
|
:currentPage="currentPage"></note-abstract>
|
|
|
|
|
<!-- 分页 -->
|
|
|
|
|
<pagation
|
|
|
|
|
class="pagation"
|
|
|
|
|
:total="posts.length"
|
|
|
|
|
:currentPage="currentPage"
|
2019-10-08 22:57:03 +08:00
|
|
|
|
@getCurrentPage="getCurrentPage" />
|
2019-10-04 22:35:38 +08:00
|
|
|
|
</div>
|
2019-06-18 18:41:09 +08:00
|
|
|
|
<div class="info-wrapper">
|
2019-10-09 09:45:19 +08:00
|
|
|
|
<img class="personal-img" :src="$frontmatter.faceImage ? $withBase($frontmatter.faceImage) : require('../images/home-head.png')" alt="hero">
|
|
|
|
|
<h3 class="name" v-if="$themeConfig.author || $site.title">{{ $themeConfig.author || $site.title }}</h3>
|
|
|
|
|
<div class="num">
|
|
|
|
|
<div>
|
|
|
|
|
<h3>{{getPagesLength}}</h3>
|
|
|
|
|
<h6>文章</h6>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<h3>{{$tags.list.length}}</h3>
|
|
|
|
|
<h6>标签</h6>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<hr>
|
|
|
|
|
<h4><i class="iconfont reco-category"></i> 分类</h4>
|
|
|
|
|
<ul class="category-wrapper">
|
2019-07-06 02:00:12 +08:00
|
|
|
|
<li class="category-item" v-for="(item, index) in this.$categories.list" :key="index">
|
2019-07-25 17:50:23 +08:00
|
|
|
|
<router-link :to="item.path">
|
2019-07-06 02:00:12 +08:00
|
|
|
|
<span class="category-name">{{ item.name }}</span>
|
2019-11-13 19:16:08 +08:00
|
|
|
|
<span class="post-num" :style="{ 'backgroundColor': _tagColor() }">{{ item.pages.length }}</span>
|
2019-07-25 17:50:23 +08:00
|
|
|
|
</router-link>
|
2019-07-06 02:00:12 +08:00
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
<hr>
|
2019-11-03 18:05:42 +08:00
|
|
|
|
<h4 v-if="$tags.list.length !== 0"><i class="iconfont reco-tag"></i> 标签</h4>
|
2019-11-13 19:05:04 +08:00
|
|
|
|
<TagList @getCurrentTag="getPagesByTags" />
|
|
|
|
|
<h4 v-if="$themeConfig.friendLink && $themeConfig.friendLink.length !== 0"><i class="iconfont reco-tag"></i> 友链</h4>
|
|
|
|
|
<FriendLink />
|
2019-09-20 13:54:13 +08:00
|
|
|
|
</div>
|
2019-06-18 18:41:09 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Content class="home-center" custom/>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2019-10-06 23:48:35 +08:00
|
|
|
|
import TagList from '@theme/components/TagList.vue'
|
2019-11-13 19:05:04 +08:00
|
|
|
|
import FriendLink from '@theme/components/FriendLink.vue'
|
2019-06-18 18:41:09 +08:00
|
|
|
|
import NoteAbstract from '@theme/components/NoteAbstract.vue'
|
2019-10-20 21:45:40 +08:00
|
|
|
|
import mixin from '@theme/mixins/index.js'
|
2019-06-18 18:41:09 +08:00
|
|
|
|
|
|
|
|
|
export default {
|
2019-10-20 21:45:40 +08:00
|
|
|
|
mixins: [mixin],
|
2019-11-13 19:05:04 +08:00
|
|
|
|
components: { NoteAbstract, TagList, FriendLink },
|
2019-06-18 18:41:09 +08:00
|
|
|
|
data () {
|
|
|
|
|
return {
|
2019-07-06 02:00:12 +08:00
|
|
|
|
recoShow: false,
|
2019-10-04 22:35:38 +08:00
|
|
|
|
currentPage: 1,
|
2019-09-20 13:54:13 +08:00
|
|
|
|
tags: []
|
2019-06-18 18:41:09 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
// 时间降序后的博客列表
|
|
|
|
|
posts () {
|
2019-10-27 20:34:46 +08:00
|
|
|
|
const {
|
|
|
|
|
$site: { pages },
|
|
|
|
|
_filterPostData,
|
|
|
|
|
_sortPostData
|
|
|
|
|
} = this
|
|
|
|
|
|
|
|
|
|
let posts = pages
|
|
|
|
|
posts = _filterPostData(posts)
|
|
|
|
|
_sortPostData(posts)
|
|
|
|
|
|
2019-06-18 18:41:09 +08:00
|
|
|
|
return posts
|
|
|
|
|
},
|
2019-07-06 02:00:12 +08:00
|
|
|
|
// 分类信息
|
2019-07-14 21:32:19 +08:00
|
|
|
|
getPagesLength () {
|
2019-10-27 20:34:46 +08:00
|
|
|
|
return this.posts.length
|
2019-07-06 02:00:12 +08:00
|
|
|
|
},
|
2019-09-20 13:54:13 +08:00
|
|
|
|
actionLink () {
|
2019-10-27 20:34:46 +08:00
|
|
|
|
const {
|
|
|
|
|
actionLink: link,
|
|
|
|
|
actionText: text
|
2019-11-01 19:32:52 +08:00
|
|
|
|
} = this.$frontmatter
|
2019-10-27 20:34:46 +08:00
|
|
|
|
|
2019-06-18 18:41:09 +08:00
|
|
|
|
return {
|
2019-10-27 20:34:46 +08:00
|
|
|
|
link,
|
|
|
|
|
text
|
2019-09-20 13:54:13 +08:00
|
|
|
|
}
|
2019-06-18 18:41:09 +08:00
|
|
|
|
},
|
|
|
|
|
heroImageStyle () {
|
2019-11-01 19:32:52 +08:00
|
|
|
|
return this.$frontmatter.heroImageStyle || {
|
2019-06-18 18:41:09 +08:00
|
|
|
|
maxHeight: '200px',
|
|
|
|
|
margin: '6rem auto 1.5rem'
|
|
|
|
|
}
|
2019-07-06 02:00:12 +08:00
|
|
|
|
},
|
|
|
|
|
bgImageStyle () {
|
2019-10-27 20:34:46 +08:00
|
|
|
|
const initBgImageStyle = {
|
2019-07-06 02:00:12 +08:00
|
|
|
|
height: '350px',
|
|
|
|
|
textAlign: 'center',
|
|
|
|
|
overflow: 'hidden'
|
|
|
|
|
}
|
2019-10-27 20:34:46 +08:00
|
|
|
|
const {
|
|
|
|
|
bgImageStyle
|
2019-11-01 19:32:52 +08:00
|
|
|
|
} = this.$frontmatter
|
2019-10-04 22:35:38 +08:00
|
|
|
|
|
2019-10-27 20:34:46 +08:00
|
|
|
|
return bgImageStyle ? { ...initBgImageStyle, ...bgImageStyle } : initBgImageStyle
|
|
|
|
|
},
|
2019-10-04 22:35:38 +08:00
|
|
|
|
heroHeight () {
|
|
|
|
|
return document.querySelector('.hero').clientHeight
|
2019-07-06 02:00:12 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2019-06-18 18:41:09 +08:00
|
|
|
|
mounted () {
|
|
|
|
|
this.recoShow = true
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2019-10-04 22:35:38 +08:00
|
|
|
|
// 获取当前页码
|
|
|
|
|
getCurrentPage (page) {
|
|
|
|
|
this._setPage(page)
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
window.scrollTo(0, this.heroHeight)
|
|
|
|
|
}, 100)
|
|
|
|
|
},
|
2019-06-18 18:41:09 +08:00
|
|
|
|
// 根据分类获取页面数据
|
|
|
|
|
getPages () {
|
|
|
|
|
let pages = this.$site.pages
|
|
|
|
|
pages = pages.filter(item => {
|
2019-10-17 19:33:21 +08:00
|
|
|
|
const { home, date } = item.frontmatter
|
|
|
|
|
return !(home == true || date === undefined)
|
2019-06-18 18:41:09 +08:00
|
|
|
|
})
|
|
|
|
|
// reverse()是为了按时间最近排序排序
|
|
|
|
|
this.pages = pages.length == 0 ? [] : pages
|
|
|
|
|
},
|
2019-07-06 02:00:12 +08:00
|
|
|
|
getPagesByTags (currentTag) {
|
2019-07-25 17:50:23 +08:00
|
|
|
|
const base = this.$site.base
|
2019-08-31 01:32:53 +08:00
|
|
|
|
window.location.href = `${base}tag/?tag=${currentTag}`
|
2019-07-06 02:00:12 +08:00
|
|
|
|
},
|
2019-10-04 22:35:38 +08:00
|
|
|
|
_setPage (page) {
|
|
|
|
|
this.currentPage = page
|
|
|
|
|
this.$page.currentPage = page
|
2019-10-08 22:57:03 +08:00
|
|
|
|
}
|
2019-06-18 18:41:09 +08:00
|
|
|
|
}
|
2019-09-20 13:54:13 +08:00
|
|
|
|
}
|
2019-06-18 18:41:09 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="stylus">
|
2019-10-17 14:28:37 +08:00
|
|
|
|
@require '../styles/recoConfig.styl'
|
2019-06-18 18:41:09 +08:00
|
|
|
|
@require '../styles/loadMixin.styl'
|
|
|
|
|
|
|
|
|
|
.home-blog {
|
|
|
|
|
padding: $navbarHeight 0 0;
|
|
|
|
|
margin: 0px auto;
|
|
|
|
|
|
|
|
|
|
.hero {
|
|
|
|
|
figure {
|
|
|
|
|
position absolute
|
|
|
|
|
background yellow
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h1 {
|
2019-07-25 19:01:14 +08:00
|
|
|
|
margin:7rem auto 1.8rem;
|
2019-06-18 18:41:09 +08:00
|
|
|
|
font-size: 2.5rem;
|
2019-07-20 19:00:36 +08:00
|
|
|
|
color #fff;
|
2019-06-18 18:41:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h1, .description, .action, .huawei {
|
|
|
|
|
color #fff!important
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.description {
|
|
|
|
|
margin: 1.8rem auto;
|
|
|
|
|
font-size: 1.6rem;
|
|
|
|
|
line-height: 1.3;
|
|
|
|
|
color: lighten($textColor, 20%);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-06 02:00:12 +08:00
|
|
|
|
.home-blog-wrapper {
|
2019-06-18 18:41:09 +08:00
|
|
|
|
display flex
|
|
|
|
|
align-items: flex-start;
|
|
|
|
|
margin 20px auto 0
|
|
|
|
|
max-width 1126px
|
2019-10-11 15:08:45 +08:00
|
|
|
|
.abstract-wrapper {
|
|
|
|
|
.abstract-item:last-child {
|
|
|
|
|
margin-bottom: 0px;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-08 22:57:03 +08:00
|
|
|
|
.blog-list {
|
|
|
|
|
flex auto
|
|
|
|
|
}
|
2019-06-18 18:41:09 +08:00
|
|
|
|
.info-wrapper {
|
2019-10-11 14:41:25 +08:00
|
|
|
|
position: -webkit-sticky;
|
|
|
|
|
position: sticky;
|
|
|
|
|
top: 70px;
|
2019-06-18 18:41:09 +08:00
|
|
|
|
transition all .3s
|
|
|
|
|
margin-left 15px;
|
2019-10-09 10:44:26 +08:00
|
|
|
|
flex 0 0 300px
|
2019-06-18 18:41:09 +08:00
|
|
|
|
height auto;
|
2019-10-17 14:28:37 +08:00
|
|
|
|
box-shadow $boxShadow;
|
|
|
|
|
border-radius $borderRadius
|
2019-07-06 02:00:12 +08:00
|
|
|
|
box-sizing border-box
|
|
|
|
|
padding 0 15px
|
2019-06-18 18:41:09 +08:00
|
|
|
|
&:hover {
|
2019-10-17 14:28:37 +08:00
|
|
|
|
box-shadow: $boxShadowHover;
|
2019-06-18 18:41:09 +08:00
|
|
|
|
}
|
|
|
|
|
.personal-img {
|
|
|
|
|
display block
|
|
|
|
|
margin 2rem auto
|
|
|
|
|
width 8rem
|
|
|
|
|
height 8rem
|
|
|
|
|
}
|
|
|
|
|
.name {
|
|
|
|
|
text-align center
|
|
|
|
|
}
|
|
|
|
|
.num {
|
|
|
|
|
display flex
|
|
|
|
|
margin 0 auto 1rem
|
|
|
|
|
width 80%
|
|
|
|
|
> div {
|
|
|
|
|
text-align center
|
|
|
|
|
flex auto
|
|
|
|
|
&:first-child {
|
|
|
|
|
border-right 1px solid #333
|
|
|
|
|
}
|
2019-07-06 02:00:12 +08:00
|
|
|
|
h3 {
|
|
|
|
|
line-height auto
|
|
|
|
|
margin 0 0 .6rem
|
|
|
|
|
color $textColor
|
|
|
|
|
}
|
|
|
|
|
h6 {
|
|
|
|
|
line-height auto
|
|
|
|
|
margin 0
|
2019-06-18 18:41:09 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-06 02:00:12 +08:00
|
|
|
|
.category-wrapper {
|
|
|
|
|
list-style none
|
|
|
|
|
padding-left 0
|
|
|
|
|
.category-item {
|
2019-10-04 22:50:05 +08:00
|
|
|
|
margin-bottom .4rem
|
2019-07-06 02:00:12 +08:00
|
|
|
|
padding: .4rem .8rem;
|
2019-09-20 13:54:13 +08:00
|
|
|
|
transition: all .5s
|
2019-10-17 14:28:37 +08:00
|
|
|
|
border-radius $borderRadius
|
|
|
|
|
box-shadow $boxShadow
|
2019-07-06 02:00:12 +08:00
|
|
|
|
&:hover {
|
2019-11-13 19:16:08 +08:00
|
|
|
|
transform scale(1.04)
|
2019-07-06 02:00:12 +08:00
|
|
|
|
}
|
|
|
|
|
a {
|
|
|
|
|
display flex
|
|
|
|
|
justify-content: space-between
|
|
|
|
|
.post-num {
|
|
|
|
|
width 1.6rem;
|
|
|
|
|
height 1.6rem
|
|
|
|
|
text-align center
|
|
|
|
|
line-height 1.6rem
|
2019-10-17 14:28:37 +08:00
|
|
|
|
border-radius $borderRadius
|
2019-07-06 02:00:12 +08:00
|
|
|
|
background #eee
|
|
|
|
|
font-size .6rem
|
2019-11-13 19:16:08 +08:00
|
|
|
|
color #fff
|
2019-07-06 02:00:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-18 18:41:09 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-20 23:01:42 +08:00
|
|
|
|
.reco-hide {
|
2019-06-18 18:41:09 +08:00
|
|
|
|
.hero {
|
|
|
|
|
img {
|
|
|
|
|
load-start()
|
|
|
|
|
}
|
2019-07-20 23:01:42 +08:00
|
|
|
|
h1 {
|
2019-06-18 18:41:09 +08:00
|
|
|
|
load-start()
|
2019-07-20 23:01:42 +08:00
|
|
|
|
color red
|
2019-06-18 18:41:09 +08:00
|
|
|
|
}
|
|
|
|
|
.description {
|
|
|
|
|
load-start()
|
|
|
|
|
}
|
|
|
|
|
.huawei {
|
|
|
|
|
load-start()
|
|
|
|
|
}
|
|
|
|
|
.action-button {
|
|
|
|
|
load-start()
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-20 23:01:42 +08:00
|
|
|
|
.home-blog-wrapper {
|
2019-06-18 18:41:09 +08:00
|
|
|
|
load-start()
|
|
|
|
|
}
|
|
|
|
|
.home-center {
|
|
|
|
|
load-start()
|
|
|
|
|
padding 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-20 23:01:42 +08:00
|
|
|
|
.reco-show {
|
2019-06-18 18:41:09 +08:00
|
|
|
|
.hero {
|
|
|
|
|
img {
|
|
|
|
|
load-end(0.08s)
|
|
|
|
|
}
|
2019-07-20 23:01:42 +08:00
|
|
|
|
h1 {
|
2019-06-18 18:41:09 +08:00
|
|
|
|
load-end(0.16s)
|
|
|
|
|
}
|
|
|
|
|
.description {
|
|
|
|
|
load-end(0.24s)
|
|
|
|
|
}
|
|
|
|
|
.huawei {
|
|
|
|
|
load-end(0.32s)
|
|
|
|
|
}
|
|
|
|
|
.action-button {
|
|
|
|
|
load-end(0.4s)
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-20 23:01:42 +08:00
|
|
|
|
.home-blog-wrapper {
|
|
|
|
|
load-end(0.48s)
|
2019-06-18 18:41:09 +08:00
|
|
|
|
}
|
|
|
|
|
.home-center {
|
2019-07-20 23:01:42 +08:00
|
|
|
|
load-end(0.56s)
|
2019-06-18 18:41:09 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media (max-width: $MQMobile) {
|
2019-07-06 02:00:12 +08:00
|
|
|
|
.home-blog {
|
2019-06-18 18:41:09 +08:00
|
|
|
|
padding-left: 1.5rem;
|
|
|
|
|
padding-right: 1.5rem;
|
|
|
|
|
.hero {
|
|
|
|
|
margin 0 -1.5rem
|
2019-07-06 02:00:12 +08:00
|
|
|
|
height 350px
|
2019-06-18 18:41:09 +08:00
|
|
|
|
img {
|
|
|
|
|
max-height: 210px;
|
|
|
|
|
margin: 2rem auto 1.2rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h1 {
|
|
|
|
|
margin: 6rem auto 1.8rem ;
|
|
|
|
|
font-size: 2rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h1, .description, .action {
|
|
|
|
|
// margin: 1.2rem auto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.description {
|
|
|
|
|
font-size: 1.2rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.action-button {
|
|
|
|
|
font-size: 1rem;
|
|
|
|
|
padding: 0.6rem 1.2rem;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-06 02:00:12 +08:00
|
|
|
|
.home-blog-wrapper {
|
2019-06-18 18:41:09 +08:00
|
|
|
|
.info-wrapper {
|
2019-07-06 02:00:12 +08:00
|
|
|
|
display none!important
|
2019-06-18 18:41:09 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media (max-width: $MQMobileNarrow) {
|
2019-07-06 02:00:12 +08:00
|
|
|
|
.home-blog {
|
2019-06-18 18:41:09 +08:00
|
|
|
|
padding-left: 1.5rem;
|
|
|
|
|
padding-right: 1.5rem;
|
|
|
|
|
|
|
|
|
|
.hero {
|
|
|
|
|
margin 0 -1.5rem
|
2019-07-06 02:00:12 +08:00
|
|
|
|
height 350px
|
2019-06-18 18:41:09 +08:00
|
|
|
|
img {
|
|
|
|
|
max-height: 210px;
|
|
|
|
|
margin: 2rem auto 1.2rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h1 {
|
|
|
|
|
margin: 6rem auto 1.8rem ;
|
|
|
|
|
font-size: 2rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h1, .description, .action {
|
|
|
|
|
// margin: 1.2rem auto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.description {
|
|
|
|
|
font-size: 1.2rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.action-button {
|
|
|
|
|
font-size: 1rem;
|
|
|
|
|
padding: 0.6rem 1.2rem;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-06 02:00:12 +08:00
|
|
|
|
.home-blog-wrapper {
|
2019-06-18 18:41:09 +08:00
|
|
|
|
.info-wrapper {
|
2019-07-06 02:00:12 +08:00
|
|
|
|
display none!important
|
2019-06-18 18:41:09 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|