feat: 前端新增中英文多语言支持

- 引入 vue-i18n,新增 locales/messages.ts 以中英对照方式维护词条
- 新增 LocaleSwitch 组件,在登录/注册页与主布局顶部栏提供切换入口
- 语言持久化到 localStorage 并同步 <html lang>,Naive UI 组件语言联动
- 各视图、表格列、弹窗与提示文案全部接入国际化
- 修复 confirmImport 缺失的 tagIds 类型定义
This commit is contained in:
2026-09-17 17:03:49 +08:00
parent 65c0d8c550
commit 179e9b78ca
15 changed files with 806 additions and 351 deletions
+30
View File
@@ -0,0 +1,30 @@
<script setup lang="ts">
// 语言切换下拉组件:供主布局顶部栏与登录/注册页复用
import { computed } from 'vue'
import { NSelect } from 'naive-ui'
import { useI18n } from 'vue-i18n'
import { setLocale, type LocaleKey } from '../locales'
const { t, locale } = useI18n()
// 语言选项:名称始终以自身语言展示
const options = computed(() => [
{ label: t('locale.zhCN'), value: 'zh-CN' },
{ label: t('locale.enUS'), value: 'en-US' },
])
/** 切换语言 */
function handleUpdate(value: LocaleKey) {
setLocale(value)
}
</script>
<template>
<NSelect
:value="locale"
:options="options"
size="small"
style="width: 120px;"
@update:value="handleUpdate"
/>
</template>