Browse Source

feat:将所有 router.push() 改为 router.replace()

zhangwl 2 months ago
parent
commit
f8a220dcf5
1 changed files with 3 additions and 3 deletions
  1. 3 3
      chat-ai-ui-main/src/App.vue

+ 3 - 3
chat-ai-ui-main/src/App.vue

@@ -32,17 +32,17 @@ onMounted(async () => {
 
 
       // 清除 URL 中的参数,然后导航到聊天页面
       // 清除 URL 中的参数,然后导航到聊天页面
       window.history.replaceState({}, '', '/chat');
       window.history.replaceState({}, '', '/chat');
-      router.push('/chat');
+      router.replace('/chat');
     } catch (error) {
     } catch (error) {
       console.error('Token verification failed:', error);
       console.error('Token verification failed:', error);
       router.push('/');
       router.push('/');
     }
     }
   } else if (!userStore.userId) {
   } else if (!userStore.userId) {
     // 如果没有 token 且用户未登录,跳转到登录页
     // 如果没有 token 且用户未登录,跳转到登录页
-    router.push('/');
+    router.replace('/');
   } else {
   } else {
     // 用户已登录,跳转到聊天页面
     // 用户已登录,跳转到聊天页面
-    router.push('/chat');
+    router.replace('/chat');
   }
   }
 });
 });
 </script>
 </script>