Files
admin/www/app/components/AppHeader.vue
T

48 lines
1.6 KiB
Vue
Raw Normal View History

<script setup lang="ts">
const { t, locale, locales } = useI18n();
const switchLocalePath = useSwitchLocalePath();
const navItems = computed(() => [
{ label: t('nav.home'), path: '/' },
{ label: t('nav.products'), path: '/products' },
{ label: t('nav.news'), path: '/news' },
{ label: t('nav.about'), path: '/about' }
]);
</script>
<template>
<header class="sticky top-0 z-50 bg-white/80 backdrop-blur-md border-b border-gray-100 dark:bg-dark-900/80 dark:border-dark-700">
<div class="section-container h-64px flex items-center justify-between">
<!-- Logo -->
<NuxtLink :to="switchLocalePath(locale)" class="flex items-center gap-8px text-xl font-bold text-primary">
{{ t('app.name') }}
</NuxtLink>
<!-- 导航 -->
<nav class="hidden md:flex items-center gap-24px">
<NuxtLink
v-for="item in navItems"
:key="item.path"
:to="switchLocalePath(locale) === '/' ? item.path : switchLocalePath(locale) + item.path"
class="text-sm text-gray-600 hover:text-primary transition-colors dark:text-gray-300"
>
{{ item.label }}
</NuxtLink>
</nav>
<!-- 语言切换 -->
<div class="flex items-center gap-12px">
<NuxtLink
v-for="loc in locales"
:key="loc.code"
:to="switchLocalePath(loc.code)"
class="px-8px py-4px rounded text-sm transition-colors"
:class="locale === loc.code ? 'bg-primary text-white' : 'text-gray-500 hover:text-primary'"
>
{{ loc.code === 'zh' ? '中' : 'EN' }}
</NuxtLink>
</div>
</div>
</header>
</template>