docs_vue2/layouts/default.vue

121 lines
2.4 KiB
Vue
Raw Normal View History

2020-08-13 11:47:56 +08:00
<template>
<config-provider :value="config">
<main
:class="{
'post-layout': true,
'no-links': !hasFooterLinks
}"
>
<one-menu
:nav="nav"
:expanded="expanded"
@toggle="handleToggle"
/>
<nuxt/>
<one-footer
class="footer"
:nav="nav"
@update="updateLayout"
/>
<one-back-to-top/>
</main>
</config-provider>
2020-08-13 11:47:56 +08:00
</template>
<script>
import 'focus-visible'
import { ConfigProvider } from 'veui'
import i18nMgr from 'veui/managers/i18n'
2020-08-13 11:47:56 +08:00
import OneMenu from '../components/OneMenu'
import OneFooter from '../components/OneFooter'
import OneBackToTop from '../components/OneBackToTop'
import nav from '../common/nav'
2020-08-13 11:47:56 +08:00
import i18n from '../common/i18n'
export default {
name: 'main-doc',
components: {
ConfigProvider,
2020-08-13 11:47:56 +08:00
OneMenu,
OneFooter,
OneBackToTop
},
mixins: [i18n],
data () {
return {
hasFooterLinks: true,
config: {
'link.routerLink': 'nuxt-link'
},
expanded: false
2020-08-13 11:47:56 +08:00
}
},
computed: {
nav () {
return nav[this.locale]
}
},
watch: {
locale: {
handler (val) {
if (i18nMgr.locale !== val) {
i18nMgr.locale = val
}
if (this.$i18n.locale !== val) {
this.$i18n.locale = val
}
if (process.env.VUE_ENV !== 'server') {
document.documentElement.setAttribute('lang', val)
const { docsearchInstance } = window
if (docsearchInstance) {
docsearchInstance.autocomplete
.eq(0)
.data('aaAutocomplete')
.dropdown.datasets[0].clearCachedSuggestions()
docsearchInstance.client.clearCache()
docsearchInstance.algoliaOptions.facetFilters = [`lang:${val}`]
}
}
},
immediate: true
}
},
methods: {
updateLayout ({ hasLinks }) {
this.hasFooterLinks = hasLinks
},
handleToggle (expanded) {
this.expanded = expanded
2020-08-13 11:47:56 +08:00
}
}
}
</script>
<style lang="stylus" scoped>
$sidebar-width = 280px
2020-08-13 11:47:56 +08:00
main
height 100%
.content
.footer
max-width 1346px - $sidebar-width
2020-08-13 11:47:56 +08:00
min-width 560px
transition margin-left 0.5s cubic-bezier(0.785, 0.135, 0.15, 0.86)
@media (max-width 480px)
.content
.footer
min-width 0
2020-08-13 11:47:56 +08:00
</style>
2021-09-25 15:17:57 +08:00
2021-10-28 17:03:43 +08:00
<style lang="stylus">
.one-toc
position absolute
left 100%
top 120px
</style>
2021-09-25 15:17:57 +08:00
<style lang="stylus" src="@/assets/styles/post.styl"></style>