Skip to content

Commit

Permalink
feat: 首页配置中添加隐藏右侧边栏配置项
Browse files Browse the repository at this point in the history
  • Loading branch information
xugaoyi committed Apr 21, 2022
1 parent 8f3df4a commit 523133d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ features: # 可选的
# 文章列表显示方式: detailed 默认,显示详细版文章列表(包括作者、分类、标签、摘要、分页等)| simple => 显示简约版文章列表(仅标题和日期)| none 不显示文章列表
# postList: detailed
# simplePostListLength: 10 # 简约版文章列表显示的文章数量,默认10。(仅在postList设置为simple时生效)
# hideRightBar: true # 是否隐藏右侧边栏
---


Expand Down
34 changes: 17 additions & 17 deletions vdoing/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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="
Expand Down Expand Up @@ -177,7 +177,7 @@ const MOBILE_DESKTOP_BREAKPOINT = 720 // refer to config.styl
BScroll.use(Slide)
export default {
data () {
data() {
return {
isMQMobile: false,
Expand All @@ -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时,不显示背景
Expand All @@ -231,21 +231,21 @@ export default {
}
},
actionLink () {
actionLink() {
return {
link: this.homeData.actionLink,
text: this.homeData.actionText
};
}
},
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; // vupress在打包时不能在beforeCreate(),created()访问浏览器api(如window)
},
mounted () {
mounted() {
if (this.$route.query.p) {
this.currentPage = Number(this.$route.query.p)
}
Expand All @@ -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 {
Expand All @@ -287,7 +287,7 @@ export default {
}
},
methods: {
init () {
init() {
clearTimeout(this.playTimer)
this.slide = new BScroll(this.$refs.slide, {
scrollX: true, // x轴滚动
Expand Down Expand Up @@ -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
Expand Down

1 comment on commit 523133d

@vercel
Copy link

@vercel vercel bot commented on 523133d Apr 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.