feat: 进入主页同步登录页语言
This commit is contained in:
@@ -62,10 +62,8 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onInput(val, index) {
|
onInput(val, index) {
|
||||||
console.log("input", val, index);
|
|
||||||
clearTimeout(this.timeout);
|
clearTimeout(this.timeout);
|
||||||
this.timeout = setTimeout(() => {
|
this.timeout = setTimeout(() => {
|
||||||
console.log("input=>", val, index);
|
|
||||||
// val = val.replace(/[^0-9]/g, '');
|
// val = val.replace(/[^0-9]/g, '');
|
||||||
val = String(val).replace(/\D/g, "");
|
val = String(val).replace(/\D/g, "");
|
||||||
this.getCtData[index] = val;
|
this.getCtData[index] = val;
|
||||||
|
|||||||
@@ -1131,7 +1131,21 @@ export default defineComponent({
|
|||||||
document.addEventListener('click', this.operateClick)
|
document.addEventListener('click', this.operateClick)
|
||||||
}
|
}
|
||||||
this.getCredits()
|
this.getCredits()
|
||||||
this.getLang('')
|
// 获取用户语言并检查是否需要与 localStorage 中的 loginLanguage 同步
|
||||||
|
this.getLang('').then(userLanguage => {
|
||||||
|
// 检查 localStorage 中的 loginLanguage
|
||||||
|
const loginLanguage = localStorage.getItem('loginLanguage')
|
||||||
|
if (loginLanguage && userLanguage && loginLanguage !== userLanguage) {
|
||||||
|
// 如果 loginLanguage 与用户当前语言不同,则更新用户语言
|
||||||
|
this.setLocale(loginLanguage)
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
// 如果获取用户语言失败,也检查 localStorage
|
||||||
|
const loginLanguage = localStorage.getItem('loginLanguage')
|
||||||
|
if (loginLanguage && loginLanguage !== this.locale) {
|
||||||
|
this.setLocale(loginLanguage)
|
||||||
|
}
|
||||||
|
})
|
||||||
//语言适配
|
//语言适配
|
||||||
|
|
||||||
let tl1 = gsap.timeline({ paused: true })
|
let tl1 = gsap.timeline({ paused: true })
|
||||||
@@ -1293,11 +1307,13 @@ export default defineComponent({
|
|||||||
//获取当前语言
|
//获取当前语言
|
||||||
getLang(v) {
|
getLang(v) {
|
||||||
let data
|
let data
|
||||||
Https.axiosPost(Https.httpUrls.getUserLanguage, data).then(rv => {
|
return Https.axiosPost(Https.httpUrls.getUserLanguage, data).then(rv => {
|
||||||
if (rv) {
|
if (rv) {
|
||||||
this.locale = rv
|
this.locale = rv
|
||||||
setLang(rv)
|
setLang(rv)
|
||||||
|
return rv
|
||||||
}
|
}
|
||||||
|
return null
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
setLang(v) {
|
setLang(v) {
|
||||||
@@ -1327,6 +1343,10 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setLocale(v) {
|
setLocale(v) {
|
||||||
|
// 同步更新 localStorage 中的 loginLanguage
|
||||||
|
if (v) {
|
||||||
|
localStorage.setItem('loginLanguage', v)
|
||||||
|
}
|
||||||
this.setLang(v)
|
this.setLang(v)
|
||||||
},
|
},
|
||||||
openTask(data) {
|
openTask(data) {
|
||||||
|
|||||||
Reference in New Issue
Block a user