feat(layout): 添加语言切换功能并优化模板结构
Some checks failed
CI/CD Pipeline / playwright (push) Successful in 2m42s
CI/CD Pipeline / build-and-deploy (push) Successful in 2m56s
测试最新依赖 / build-and-test (push) Failing after 1m38s
测试最新依赖 / playwright (push) Successful in 2m31s

This commit is contained in:
严浩
2025-10-23 23:56:58 +08:00
parent c9b75f55cc
commit d816110b4b

View File

@@ -14,10 +14,20 @@ const themeLabels: Record<AppThemeMode, string> = {
dark: '深色',
system: '跟随系统',
};
const { locale } = useI18n();
const languageLabels: Record<string, string> = {
'en-US': 'English',
'zh-CN': '简体中文',
};
function toggleLanguage() {
locale.value = locale.value === 'zh-CN' ? 'en-US' : 'zh-CN';
}
</script>
<template>
<div class="h-full flex items-center justify-between px-12px shadow-header dark:shadow-gray-700">
<div>
<NTooltip :disabled="appStore.isMobile" placement="bottom-start">
{{ appStore.sidebarCollapsed ? '展开菜单' : '收起菜单' }}
<template #trigger>
@@ -27,7 +37,17 @@ const themeLabels: Record<AppThemeMode, string> = {
</NButton>
</template>
</NTooltip>
</div>
<div class="flex items-center">
<NTooltip :disabled="appStore.isMobile" placement="bottom-end">
{{ languageLabels[locale] }}
<template #trigger>
<NButton quaternary @click="toggleLanguage">
<icon-clarity:language-line w-4.5 h-4.5 />
</NButton>
</template>
</NTooltip>
<NTooltip :disabled="appStore.isMobile" placement="bottom-end">
{{ themeLabels[appStore.themeMode] }}
<template #trigger>
@@ -47,4 +67,5 @@ const themeLabels: Record<AppThemeMode, string> = {
</template>
</NTooltip>
</div>
</div>
</template>