fix: 登录/注册支持 redirect 参数,未登录跳转自动携带来源页
- login.js/register.js 登录成功后优先跳转 redirect 参数指定页面 - 新增 common.RedirectToLogin 辅助函数,自动携带当前路径 - 替换所有 9 处硬编码 /auth/login 重定向
This commit is contained in:
@ -32,6 +32,13 @@
|
||||
// Guard: exit if not on auth page
|
||||
if (!registerForm) return;
|
||||
|
||||
// 读取 redirect 参数(注册成功后跳转目标)
|
||||
function getRedirect() {
|
||||
var m = window.location.search.match(/[?&]redirect=([^&]+)/);
|
||||
if (m) return decodeURIComponent(m[1]);
|
||||
return '/';
|
||||
}
|
||||
|
||||
var countdown = 60;
|
||||
var timerInterval = null;
|
||||
var reachedBottom = false;
|
||||
@ -287,7 +294,7 @@
|
||||
// Token 已通过 HttpOnly Cookie 自动设置,JS 无需处理
|
||||
// 注册即登录,跳转首页
|
||||
setTimeout(function () {
|
||||
window.location.href = '/';
|
||||
window.location.href = getRedirect();
|
||||
}, 1500);
|
||||
} else {
|
||||
var msg = (resp && resp.message) ? resp.message : '注册失败,请稍后重试';
|
||||
|
||||
Reference in New Issue
Block a user