mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-21 04:50:14 +08:00
fb442a92ad
Add installation, usage, support platforms
51 lines
1.2 KiB
Vue
51 lines
1.2 KiB
Vue
<template>
|
|
<n-service-layout
|
|
ref="layoutInstRef"
|
|
:padding-body="false"
|
|
:items="options"
|
|
:sider-props="siderProps"
|
|
>
|
|
<router-view />
|
|
</n-service-layout>
|
|
</template>
|
|
|
|
<script>
|
|
// Frame component for components & docs page
|
|
import { computed, watch, toRef, ref } from 'vue'
|
|
import { useRoute } from 'vue-router'
|
|
import { useDocOptions, useComponentOptions } from '../store'
|
|
|
|
export default {
|
|
setup () {
|
|
const route = useRoute()
|
|
const layoutInstRef = ref(null)
|
|
const docOptionsRef = useDocOptions()
|
|
const componentOptionsRef = useComponentOptions()
|
|
const optionsRef = computed(() =>
|
|
route.path.includes('/docs/')
|
|
? docOptionsRef.value
|
|
: componentOptionsRef.value
|
|
)
|
|
watch(toRef(route, 'path'), (value, oldValue) => {
|
|
const langAndThemeReg = /\/(zh-CN|en-US)\/(light|dark|os-theme)/g
|
|
// only theme & lang change do not restore the scroll status
|
|
if (
|
|
value.replace(langAndThemeReg, '') !==
|
|
oldValue.replace(langAndThemeReg, '')
|
|
) {
|
|
layoutInstRef.value.scrollTo(0, 0)
|
|
}
|
|
})
|
|
return {
|
|
layoutInstRef,
|
|
options: optionsRef,
|
|
siderProps: {
|
|
style: {
|
|
height: '100%'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|