Просмотр исходного кода

fix(logout): reLaunch first then clear auth state to avoid hang

xuyunhui 1 неделя назад
Родитель
Сommit
b0b08c38c3
1 измененных файлов с 6 добавлено и 3 удалено
  1. 6 3
      src/components/my/ProfileView.vue

+ 6 - 3
src/components/my/ProfileView.vue

@@ -128,9 +128,12 @@ async function handleLogout() {
     content: '确定要退出登录吗?',
   })
   if (res.confirm) {
-    await authStore.doLogout()
-    uni.showToast({ title: '已退出登录', icon: 'none' })
-    uni.reLaunch({ url: '/pages/login/login' })
+    uni.reLaunch({
+      url: '/pages/login/login',
+      complete: () => {
+        authStore.doLogout()
+      },
+    })
   }
 }
 </script>