官网开发 0810-v2

This commit is contained in:
eafonyang
2026-08-10 18:50:14 +08:00
parent 48510739a7
commit d41f77b49c
23 changed files with 875 additions and 60 deletions
+30 -4
View File
@@ -11,6 +11,32 @@ const appStore = useAppStore();
const { navItems, navAppearance, productSeries, site } = storeToRefs(siteStore);
// ===== 多语言:按站点配置决定可切换的语言 =====
// 启用的语言代码;未配置时默认全部语言
const enabledLocaleCodes = computed<string[]>(() => {
const all: string[] = (unref(locales) || []).map(l => l.code);
const raw = site.value?.enabled_locales;
if (!raw) return all;
const list = raw.split(',').map(s => s.trim()).filter(c => all.includes(c));
return list.length ? list : all;
});
// 实际展示的切换按钮 = i18n locales ∩ 启用列表
const activeLocales = computed(() => (unref(locales) || []).filter(l => enabledLocaleCodes.value.includes(l.code)));
// 只启用一种语言时不显示切换按钮
const showLocaleSwitch = computed(() => activeLocales.value.length > 1);
// 当前语言被停用(如只启用中文时访问 /en/*):跳转到首个启用语言的对应页面
watch(
[enabledLocaleCodes, () => locale.value],
([codes]) => {
if (!site.value || codes.includes(locale.value)) return;
const target = codes[0];
if (target) navigateTo(switchLocalePath(target as typeof locale.value));
}
);
// 滚动状态:滚动后强制毛玻璃背景 + 深色文字
const { y: scrollY } = useWindowScroll();
const isScrolled = computed(() => scrollY.value > 24);
@@ -186,9 +212,9 @@ function closeMobile() {
<!-- 右侧语言切换 + 移动端汉堡 -->
<div class="flex items-center gap-12px">
<div class="hidden md:flex items-center gap-4px">
<div v-if="showLocaleSwitch" class="hidden md:flex items-center gap-4px">
<NuxtLink
v-for="loc in locales"
v-for="loc in activeLocales"
:key="loc.code"
:to="switchLocalePath(loc.code)"
class="px-8px py-4px rounded text-sm transition-colors"
@@ -230,9 +256,9 @@ function closeMobile() {
{{ siteStore.navLabel(item) }}
</NuxtLink>
<div class="flex items-center gap-8px mt-12px px-12px">
<div v-if="showLocaleSwitch" class="flex items-center gap-8px mt-12px px-12px">
<NuxtLink
v-for="loc in locales"
v-for="loc in activeLocales"
:key="loc.code"
:to="switchLocalePath(loc.code)"
class="px-12px py-6px rounded text-sm transition-colors"