File tree Expand file tree Collapse file tree 8 files changed +24
-90
lines changed
packages/vuepress-theme-reco Expand file tree Collapse file tree 8 files changed +24
-90
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ module.exports = {
5858 search : true ,
5959 searchMaxSuggestions : 10 ,
6060 // 自动形成侧边导航
61- // sidebar : 'auto',
61+ // subSidebar : 'auto',
6262 sidebarDepth : 4 ,
6363 // 最后更新时间
6464 lastUpdated : 'Last Updated' ,
Original file line number Diff line number Diff line change @@ -4,10 +4,14 @@ title: bar2
44
55bar2
66
7+ ## sidebar
8+
79## 二级标题1
810
911### 三级标题1-1
1012
13+
14+
1115#### 四级标题1-1-1
1216#### 四级标题1-1-2
1317#### 四级标题1-1-3
Original file line number Diff line number Diff line change @@ -134,59 +134,6 @@ export default {
134134 transform scale (1.05 )
135135 }
136136 }
137-
138- // &.reco-hide {
139- // .hero {
140- // img {
141- // load-start()
142- // }
143- // .h1 {
144- // load-start()
145- // }
146- // .description {
147- // load-start()
148- // }
149- // .huawei {
150- // load-start()
151- // }
152- // .action-button {
153- // load-start()
154- // }
155- // }
156- // .features {
157- // load-start()
158- // }
159- // .home-center {
160- // load-start()
161- // padding 0
162- // }
163- // }
164-
165- // &.reco-show {
166- // .hero {
167- // img {
168- // load-end(0.08s)
169- // }
170- // .h1 {
171- // load-end(0.16s)
172- // }
173- // .description {
174- // load-end(0.24s)
175- // }
176- // .huawei {
177- // load-end(0.32s)
178- // }
179- // .action-button {
180- // load-end(0.4s)
181- // }
182- // }
183- // .features {
184- // load-end(0.40s)
185- // }
186- // .home-center {
187- // load-end(0.48s)
188- // }
189- // }
190137}
191138
192139@media (max-width : $MQMobile) {
Original file line number Diff line number Diff line change @@ -171,8 +171,7 @@ export default {
171171 )
172172 },
173173 pageStyle () {
174- const headers = this .$page .headers || []
175- return headers .length > 0 ? {} : { paddingRight: ' 0' }
174+ return this .$showSubSideBar ? {} : { paddingRight: ' 0' }
176175 }
177176 },
178177
Original file line number Diff line number Diff line change @@ -4,17 +4,15 @@ import { isActive } from '@theme/helpers/utils'
44export default {
55 computed: {
66 headers () {
7- const headers = (this .$page .headers || []).filter (header => header .level === 2 )
8- return headers
7+ return this .showSubSidebar ? this .$page .headers || [] : []
98 }
109 },
1110 methods: {
1211 isLinkActive (header ) {
1312 const active = isActive (this .$route , this .$page .path + ' #' + header .slug )
1413 if (active) {
1514 setTimeout (() => {
16- console .log (document .querySelector (` .${ header .slug } ` ))
17- document .querySelector (` .${ header .slug } ` ).scrollIntoView ()
15+ document .querySelector (` .reco-${ header .slug } ` ).scrollIntoView ()
1816 }, 300 )
1917 }
2018 return active
@@ -23,9 +21,9 @@ export default {
2321 render (h ) {
2422 return h (' ul' , {
2523 class: { ' sub-sidebar-wrapper' : true },
26- style: { width: ( this .$page . headers || []) .length > 0 ? ' 12rem' : ' 0' }
24+ style: { width: this .headers .length > 0 ? ' 12rem' : ' 0' }
2725 }, [
28- ... ( this .$page . headers || []) .map (header => {
26+ ... this .headers .map (header => {
2927 return h (' li' , {
3028 class: {
3129 active: this .isLinkActive (header),
@@ -34,7 +32,7 @@ export default {
3432 attr: { key: header .title }
3533 }, [
3634 h (' router-link' , {
37- class: { ' sidebar-link' : true , [` ${ header .slug } ` ]: true },
35+ class: { ' sidebar-link' : true , [` reco- ${ header .slug } ` ]: true },
3836 props: { to: ` ${ this .$page .path } #${ header .slug } ` }
3937 }, header .title )
4038 ])
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -41,6 +41,18 @@ export default {
4141 }
4242
4343 return formatPagesArr
44+ } ,
45+ $showSubSideBar ( ) {
46+ const {
47+ $themeConfig : { subSidebar : themeSidebar } ,
48+ $frontmatter : { subSidebar : pageSidebar }
49+ } = this
50+ const headers = this . $page . headers || [ ]
51+
52+ if ( ( themeSidebar === 'auto' || pageSidebar === 'auto' ) && headers . length > 0 ) {
53+ return true
54+ }
55+ return false
4456 }
4557 }
4658}
Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ th, td
195195@require 'mobile.styl'
196196
197197.iconfont
198- font-size : 0.9 rem ;
198+ font-size : 12 px ;
199199 color : var (-- text - color-sub );
200200
201201/* ************* 滚动条 **************/
You can’t perform that action at this time.
0 commit comments