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

View File

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