This commit is contained in:
2025-10-11 14:56:40 +08:00
parent 9da94a6ddf
commit 47979ecca8
19 changed files with 14952 additions and 27 deletions

View File

@@ -28,7 +28,8 @@
</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="langChange"> -->
<el-dropdown style="display: flex; justify-content: right; color: #409EFF;" trigger="click" @command="changeLanguage">
<span class="el-dropdown-link">
{{ language }}
</span>
@@ -59,10 +60,11 @@
<script>
import { encrypt } from '@/utils/rsaEncrypt'
import Config from '@/settings'
import { getCodeImg } from '@/api/login'
// import { getCodeImg } from '@/api/login'
import Cookies from 'js-cookie'
import Background from '@/assets/images/background.jpg'
import i18n from '@/i18n'
import { fetchMessages } from '@/api/i18n'
export default {
name: 'Login',
data() {
@@ -107,6 +109,18 @@ export default {
this.point()
},
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
@@ -124,10 +138,10 @@ export default {
}
},
getCode() {
getCodeImg().then(res => {
this.codeUrl = res.img
this.loginForm.uuid = res.uuid
})
// getCodeImg().then(res => {
// this.codeUrl = res.img
// this.loginForm.uuid = res.uuid
// })
},
getCookie() {
const username = Cookies.get('username')