From 0ef8b3060cca07dcf34245a5bdca22d110e82e8c Mon Sep 17 00:00:00 2001 From: zhangyh Date: Tue, 25 Nov 2025 13:26:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=BF=9B=E5=85=A5=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E7=99=BB=E5=BD=95=E9=A1=B5=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LoginPage/verificationCodeInput.vue | 2 -- src/views/HomeMain.vue | 24 +++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/component/LoginPage/verificationCodeInput.vue b/src/component/LoginPage/verificationCodeInput.vue index 8f668363..4b113036 100644 --- a/src/component/LoginPage/verificationCodeInput.vue +++ b/src/component/LoginPage/verificationCodeInput.vue @@ -62,10 +62,8 @@ }, methods: { onInput(val, index) { - console.log("input", val, index); clearTimeout(this.timeout); this.timeout = setTimeout(() => { - console.log("input=>", val, index); // val = val.replace(/[^0-9]/g, ''); val = String(val).replace(/\D/g, ""); this.getCtData[index] = val; diff --git a/src/views/HomeMain.vue b/src/views/HomeMain.vue index c0a9a8b9..a7220b02 100644 --- a/src/views/HomeMain.vue +++ b/src/views/HomeMain.vue @@ -1127,7 +1127,21 @@ export default defineComponent({ document.addEventListener('click', this.operateClick) } 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 }) @@ -1289,11 +1303,13 @@ export default defineComponent({ //获取当前语言 getLang(v) { let data - Https.axiosPost(Https.httpUrls.getUserLanguage, data).then(rv => { + return Https.axiosPost(Https.httpUrls.getUserLanguage, data).then(rv => { if (rv) { this.locale = rv setLang(rv) + return rv } + return null }) }, setLang(v) { @@ -1323,6 +1339,10 @@ export default defineComponent({ }, setLocale(v) { + // 同步更新 localStorage 中的 loginLanguage + if (v) { + localStorage.setItem('loginLanguage', v) + } this.setLang(v) }, openTask(data) {