From 67addd582ff5f238d5b7a7618f92ba6036cbd1f3 Mon Sep 17 00:00:00 2001 From: dzq Date: Tue, 13 May 2025 15:33:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91=E4=BB=A5?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E9=87=8D=E5=A4=8D=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了在用户已登录时重复触发登录逻辑的问题。通过引入 `isLogin` 变量,确保只有在用户未登录时才执行登录操作并跳转页面。 --- src/App.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/App.vue b/src/App.vue index 3687a23..00aba70 100644 --- a/src/App.vue +++ b/src/App.vue @@ -46,13 +46,16 @@ onMounted(() => { watch( () => wxStore.userid, (newVal) => { - if (newVal && !ab98UserStore.isLogin) { + const isLogin = ab98UserStore.isLogin; + if (newVal) { tokenLogin(ab98UserStore.tokenLogin, newVal, wxStore.openid).then(res => { if (res?.code === 0 && res.data?.success) { ab98UserStore.setTel(res.data.tel) ab98UserStore.setUserInfo(res.data) - ab98UserStore.setIsLogin(true) - router.push('/') + if (!isLogin) { + ab98UserStore.setIsLogin(true) + router.push('/') + } } }) }