Skip to content

Commit 27a9b3b

Browse files
author
reco_luan
committed
refactor(theme): use VCA
1 parent ee86017 commit 27a9b3b

File tree

3 files changed

+27
-31
lines changed

3 files changed

+27
-31
lines changed

packages/vuepress-theme-reco/components/Footer.vue

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,25 @@
3030
</template>
3131

3232
<script>
33+
import { defineComponent, computed } from '@vue/composition-api'
3334
import { RecoIcon } from '@vuepress-reco/core/lib/components'
3435
import { 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>

packages/vuepress-theme-reco/components/Sidebar.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@
88
</template>
99

1010
<script>
11+
import { defineComponent } from '@vue/composition-api'
1112
import SidebarLinks from '@theme/components/SidebarLinks'
1213
import 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">

packages/vuepress-theme-reco/components/SubSidebar.vue

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
<script>
2+
import { defineComponent, computed } from '@vue/composition-api'
23
import { 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>

0 commit comments

Comments
 (0)