add:增加语言包依赖

This commit is contained in:
zhangzq
2025-10-14 17:17:28 +08:00
parent 3245f4dd32
commit 9a85d1bd73
21 changed files with 1491 additions and 593 deletions

View File

@@ -28,7 +28,7 @@
</el-checkbox>
</el-col>
<el-col :span="12">
<el-dropdown style="display: flex; justify-content: right; color: #409EFF;" trigger="click" @command="langChange">
<el-dropdown style="display: flex; justify-content: right; color: #409EFF;" trigger="click" @command="changeLanguage">
<span class="el-dropdown-link">
{{ language }}
</span>
@@ -108,6 +108,18 @@ export default {
},
methods: {
// 中英文切换
// 语言切换-x
async changeLanguage(locale) {
// 如果已经加载过该语言,可以直接设置,避免重复请求
if (!this.$i18n.getLocaleMessage(locale)) {
const messages = await fetchMessages(locale)
this.$i18n.setLocaleMessage(locale, messages)
}
this.$i18n.locale = locale
// 可以将当前语言保存到本地存储,以便下次使用
localStorage.setItem('lang', locale)
this.setLang(locale)
},
langChange(command) {
this.$i18n.locale = command
localStorage.setItem('lang', command)