From 82930a7f2e322b1c55c76393f1d4d37affdb920e Mon Sep 17 00:00:00 2001 From: yang chen Date: Fri, 12 Dec 2025 14:56:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(permission):=20=E4=BF=AE=E5=A4=8DSSO?= =?UTF-8?q?=E9=87=8D=E5=AE=9A=E5=90=91URL=E6=9E=84=E9=80=A0=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 正确处理路由中的查询参数 - 使用URLSearchParams构造查询字符串 - 对重定向URL进行编码以确保安全性 - 保持原有路径参数不变 - 提高SSO登录流程的稳定性 --- src/permission.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/permission.ts b/src/permission.ts index aa9f520..b461e2e 100644 --- a/src/permission.ts +++ b/src/permission.ts @@ -102,10 +102,17 @@ router.beforeEach(async (to, from, next) => { } else { if(import.meta.env.VITE_DEFAULT_SSO =='true'){ authUtil.setTenantId("1") + // 正确构造包含查询参数的重定向URL + let redirectUrl = to.fullPath; + if (Object.keys(to.query).length > 0) { + const queryParams = new URLSearchParams(to.query as Record).toString(); + redirectUrl = `${to.path}?${queryParams}`; + } + const redirectUri = location.origin + '/social-login?' + - `type=100&redirect=${to.fullPath}` + `type=100&redirect=${encodeURIComponent(redirectUrl)}` // 进行跳转 const res = await LoginApi.socialAuthRedirect(100, encodeURIComponent(redirectUri))