fix: 修复登录状态判断逻辑以避免重复登录

修复了在用户已登录时重复触发登录逻辑的问题。通过引入 `isLogin` 变量,确保只有在用户未登录时才执行登录操作并跳转页面。
This commit is contained in:
dzq 2025-05-13 15:33:49 +08:00
parent e895e5619c
commit 67addd582f
1 changed files with 6 additions and 3 deletions

View File

@ -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('/')
}
}
})
}