Browse Source

feat:1. App.vue - 添加认证逻辑

  - 在 onMounted 中检测 URL 参数 token 和 source
  - 如果有 token,调用后端接口 /users/login 验证并获取用户信息
  - 设置用户状态后,使用 window.history.replaceState() 清除 URL 参数
  - 然后导航到 /chat 页面
  - 关键:使用 replaceState 而不是 push,避免改变浏览器历史记录

  2. ChatView.vue - 移除登录检查

  - 删除了同步的登录检查逻辑
  - 认证现在在 App.vue 中统一处理
zhangwl 2 months ago
parent
commit
13ea67c849
1 changed files with 0 additions and 4 deletions
  1. 0 4
      chat-ai-ui-main/src/views/ChatView.vue

+ 0 - 4
chat-ai-ui-main/src/views/ChatView.vue

@@ -14,10 +14,6 @@ const userStore = useUserStore();
 const chatStore = useChatStore();
 const router = useRouter();
 
-// 确保用户已登录
-if (!userStore.userId) {
-  router.push('/');
-}
 // 配置标记以获得更好的呈现
 
 marked.use(markedHighlight({