26 lines
739 B
TypeScript
26 lines
739 B
TypeScript
import DefaultTheme from 'vitepress/theme'
|
|
import {useRoute} from 'vitepress'
|
|
import {watch, onMounted} from 'vue'
|
|
|
|
export default {
|
|
...DefaultTheme,
|
|
setup() {
|
|
const route = useRoute()
|
|
|
|
const updateNavVisibility = (path: string) => {
|
|
const navElement = document.querySelector('.VPNavBarMenu')
|
|
if (navElement instanceof HTMLElement) {
|
|
navElement.style.display = (path === '/' || path === '/docs/en/') ? 'none' : ''
|
|
}
|
|
}
|
|
|
|
onMounted(() => {
|
|
updateNavVisibility(route.path)
|
|
})
|
|
|
|
// 监听路由变化,处理导航栏显示
|
|
watch(() => route.path, (path) => {
|
|
updateNavVisibility(path)
|
|
})
|
|
}
|
|
} |