File tree Expand file tree Collapse file tree 3 files changed +27
-31
lines changed
packages/vuepress-theme-reco/components Expand file tree Collapse file tree 3 files changed +27
-31
lines changed Original file line number Diff line number Diff line change 3030</template >
3131
3232<script >
33+ import { defineComponent , computed } from ' @vue/composition-api'
3334import { RecoIcon } from ' @vuepress-reco/core/lib/components'
3435import { version } from ' ../package.json'
35- export default {
36+ export default defineComponent ( {
3637 components: { RecoIcon },
37-
38- data () {
39- return {
40- version
41- }
42- },
43- computed: {
44- showAccessNumber () {
38+ setup (props , ctx ) {
39+ const showAccessNumber = computed (() => {
4540 const {
4641 $themeConfig: { valineConfig },
4742 $themeLocaleConfig: { valineConfig: valineLocalConfig }
48- } = this
43+ } = ctx . root
4944
5045 const vc = valineLocalConfig || valineConfig
51- if (vc && vc .visitor != false ) {
52- return true
53- }
54- return false
55- }
46+
47+ return vc && vc .visitor != false
48+ })
49+ return { version, showAccessNumber }
5650 }
57- }
51+ })
5852 </script >
5953
6054<style lang="stylus" scoped>
Original file line number Diff line number Diff line change 88</template >
99
1010<script >
11+ import { defineComponent } from ' @vue/composition-api'
1112import SidebarLinks from ' @theme/components/SidebarLinks'
1213import NavLinks from ' @theme/components/NavLinks'
1314
14- export default {
15+ export default defineComponent ( {
1516 name: ' Sidebar' ,
16-
1717 components: { SidebarLinks, NavLinks },
18-
1918 props: [' items' ]
20- }
19+ })
2120 </script >
2221
2322<style lang="stylus">
Original file line number Diff line number Diff line change 11<script >
2+ import { defineComponent , computed } from ' @vue/composition-api'
23import { isActive } from ' @theme/helpers/utils'
34
4- export default {
5- computed: {
6- headers () {
7- return this .$showSubSideBar ? this .$page .headers : []
8- }
9- },
10- methods: {
11- isLinkActive (header ) {
12- const active = isActive (this .$route , this .$page .path + ' #' + header .slug )
5+ export default defineComponent ({
6+ setup (props , ctx ) {
7+ const { root } = ctx
8+
9+ const headers = computed (() => {
10+ return root .$showSubSideBar ? root .$page .headers : []
11+ })
12+
13+ const isLinkActive = (header ) => {
14+ const active = isActive (root .$route , root .$page .path + ' #' + header .slug )
1315 if (active) {
1416 setTimeout (() => {
1517 document .querySelector (` .reco-side-${ header .slug } ` ).scrollIntoView ()
1618 }, 300 )
1719 }
1820 return active
1921 }
22+
23+ return { headers, isLinkActive }
2024 },
2125 render (h ) {
2226 return h (' ul' , {
@@ -39,8 +43,7 @@ export default {
3943 })
4044 ])
4145 }
42- }
43-
46+ })
4447 </script >
4548
4649<style lang="stylus" scoped>
You can’t perform that action at this time.
0 commit comments