feat: 首页配置中添加隐藏右侧边栏配置项

This commit is contained in:
xugaoyi 2022-04-21 09:51:06 +08:00
parent 8f3df4a892
commit 523133d316
2 changed files with 18 additions and 17 deletions

View File

@ -24,6 +24,7 @@ features: # 可选的
# 文章列表显示方式: detailed 默认,显示详细版文章列表(包括作者、分类、标签、摘要、分页等)| simple => 显示简约版文章列表(仅标题和日期)| none 不显示文章列表
# postList: detailed
# simplePostListLength: 10 # 简约版文章列表显示的文章数量默认10。仅在postList设置为simple时生效
# hideRightBar: true # 是否隐藏右侧边栏
---

View File

@ -135,7 +135,7 @@
<Content class="theme-vdoing-content custom card-box" />
</template>
<template #mainRight>
<template v-if="!homeData.hideRightBar" #mainRight>
<BloggerBar v-if="$themeConfig.blogger" />
<CategoriesBar
v-if="
@ -177,7 +177,7 @@ const MOBILE_DESKTOP_BREAKPOINT = 720 // refer to config.styl
BScroll.use(Slide)
export default {
data () {
data() {
return {
isMQMobile: false,
@ -192,25 +192,25 @@ export default {
}
},
computed: {
homeData () {
homeData() {
return {
...this.$page.frontmatter
}
},
hasFeatures () {
hasFeatures() {
return !!(this.homeData.features && this.homeData.features.length)
},
homeSidebarB () {
homeSidebarB() {
const { htmlModules } = this.$themeConfig
return htmlModules ? htmlModules.homeSidebarB : ''
},
showBanner () { // banner
showBanner() { // banner
return this.$route.query.p
&& this.$route.query.p != 1
&& (!this.homeData.postList || this.homeData.postList === 'detailed')
? false : true
},
bannerBgStyle () {
bannerBgStyle() {
let bannerBg = this.homeData.bannerBg
if (!bannerBg || bannerBg === 'auto') { //
if (this.$themeConfig.bodyBgImg) { // bodyBgImg
@ -231,7 +231,7 @@ export default {
}
},
actionLink () {
actionLink() {
return {
link: this.homeData.actionLink,
text: this.homeData.actionText
@ -239,13 +239,13 @@ export default {
}
},
components: { NavLink, MainLayout, PostList, UpdateArticle, BloggerBar, CategoriesBar, TagsBar, Pagination },
created () {
created() {
this.total = this.$sortPosts.length
},
beforeMount () {
beforeMount() {
this.isMQMobile = window.innerWidth < MOBILE_DESKTOP_BREAKPOINT ? true : false; // vupressbeforeCreate(),created()访apiwindow
},
mounted () {
mounted() {
if (this.$route.query.p) {
this.currentPage = Number(this.$route.query.p)
}
@ -266,12 +266,12 @@ export default {
})
}
},
beforeDestroy () {
beforeDestroy() {
clearTimeout(this.playTimer)
this.slide && this.slide.destroy()
},
watch: {
'$route.query.p' () {
'$route.query.p'() {
if (!this.$route.query.p) {
this.currentPage = 1
} else {
@ -287,7 +287,7 @@ export default {
}
},
methods: {
init () {
init() {
clearTimeout(this.playTimer)
this.slide = new BScroll(this.$refs.slide, {
scrollX: true, // x
@ -317,16 +317,16 @@ export default {
})
this.autoGoNext()
},
autoGoNext () {
autoGoNext() {
clearTimeout(this.playTimer)
this.playTimer = setTimeout(() => {
this.slide.next()
}, 4000)
},
handlePagination (i) { //
handlePagination(i) { //
this.currentPage = i
},
getScrollTop () {
getScrollTop() {
return window.pageYOffset
|| document.documentElement.scrollTop
|| document.body.scrollTop