fix(permission): 修复SSO重定向URL构造问题

- 正确处理路由中的查询参数
- 使用URLSearchParams构造查询字符串
- 对重定向URL进行编码以确保安全性
- 保持原有路径参数不变
- 提高SSO登录流程的稳定性
This commit is contained in:
2025-12-12 14:56:27 +08:00
parent 7832cec925
commit 82930a7f2e

View File

@@ -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<string, string>).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))