useHeader() 配置 Header 组件的桌面端和移动端导航链接。
默认返回空数组:
export function useHeader() {
return {
desktopLinks: computed(() => []),
mobileLinks: computed(() => [])
}
}
在项目中创建 composables/useHeader.ts 覆盖默认配置:
export function useHeader() {
const route = useRoute()
return {
desktopLinks: computed(() => [
{
label: '文档',
to: '/docs',
icon: 'i-lucide-book',
active: route.path.startsWith('/docs')
},
{
label: 'API',
to: '/api',
icon: 'i-lucide-code',
active: route.path.startsWith('/api')
}
]),
mobileLinks: computed(() => [
{
label: '首页',
to: '/',
icon: 'i-lucide-square-play'
},
{
label: '文档',
to: '/docs',
icon: 'i-lucide-book'
}
])
}
}
export function useHeader() {
const { t } = useI18n()
return {
desktopLinks: computed(() => [
{
label: t('nav.docs'),
to: '/docs',
icon: 'i-lucide-book'
},
{
label: t('nav.api'),
to: '/api',
icon: 'i-lucide-code'
}
]),
mobileLinks: computed(() => [
{
label: t('nav.home'),
to: '/',
icon: 'i-lucide-square-play'
},
{
label: t('nav.docs'),
to: '/docs',
icon: 'i-lucide-book'
}
])
}
}
useHeader()返回 Header 导航链接配置。
586a5 — ✨ feat: 添加 Nuxt 文档主题 layer 核心代码