From 644510df1725ad995314f322a60c71560ba0ac70 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Tue, 3 Nov 2026 14:47:36 +0800 Subject: [PATCH] chore: handle third-party login callback and manage session token redirection --- ui/src/router/chat/index.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ui/src/router/chat/index.ts b/ui/src/router/chat/index.ts index 6cd01df4543..668e29dedcd 100644 --- a/ui/src/router/chat/index.ts +++ b/ui/src/router/chat/index.ts @@ -48,6 +48,17 @@ chatRouter.beforeEach(async (to) => { const { auth } = useStore() + // 三方登录回调:后端重定向回本地址时通过 query 携带会话 token,这里保存后去掉 query 并跳回原地址 + const callbackToken = typeof to.query.token === 'string' ? to.query.token : '' + if (callbackToken) { + const { token, redirect, ...query } = to.query + auth.setToken(callbackToken, scope) + if (typeof redirect === 'string' && redirect.startsWith('/')) return { path: redirect, query, replace: true } + return scope === PORTAL_AUTH_SCOPE + ? { name: 'portal-home', query, replace: true } + : { name: 'chat-home', params: { accessToken: scope }, query, replace: true } + } + // accessToken 无效、应用已停用或门户未开放时,认证前置配置与匿名认证会失败,统一进入 404 页面 let authProfile: AuthProfile try {