语言切换保持

main
768863620@qq.com 2024-09-20 17:35:33 +08:00
parent 9035249ad4
commit caf71c79d4
4 changed files with 6 additions and 4 deletions

View File

@ -2,8 +2,8 @@
<el-breadcrumb class="app-breadcrumb" separator="/">
<transition-group name="breadcrumb">
<el-breadcrumb-item v-for="(item,index) in levelList" :key="item.path">
<span v-if="item.redirect==='noredirect'||index==levelList.length-1" class="no-redirect">{{ item.meta.title }}</span>
<a v-else @click.prevent="handleLink(item)">{{ item.meta.title }}</a>
<span v-if="item.redirect==='noredirect'||index==levelList.length-1" class="no-redirect">{{$t(item.meta.title )}}</span>
<a v-else @click.prevent="handleLink(item)">{{$t(item.meta.title )}}</a>
</el-breadcrumb-item>
</transition-group>
</el-breadcrumb>

View File

@ -51,9 +51,9 @@ const messages = {
en: enLocale,
'zh': zhCNLocale
}
const storedLanguage = localStorage.getItem('lang') || 'zh'
const i18n = new VueI18n({
locale: 'en', // 设置默认语言
locale: storedLanguage, // 设置默认语言
messages
})

View File

@ -162,6 +162,7 @@ export default {
},
handleLogin() {
this.$i18n.locale = 'zh'
localStorage.setItem('lang', 'zh')
this.$refs.loginForm.validate(valid => {
const user = {
username: this.loginForm.username,

View File

@ -164,6 +164,7 @@ export default {
},
handleLogin() {
this.$i18n.locale = 'en'
localStorage.setItem('lang', 'en')
this.$refs.loginForm.validate(valid => {
const user = {
username: this.loginForm.username,