fix: 修复帖子详情页6处 /login 路径错误
- posts/show.html 中所有 /login 跳转改为 /auth/login - 覆盖评论登录提示、点赞/反对/收藏 401 跳转
This commit is contained in:
@ -126,7 +126,7 @@
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="comment-login-hint">
|
||||
<a href="/login?redirect=/posts/{{$.Post.ID}}">登录</a> 后参与评论
|
||||
<a href="/auth/login?redirect=/posts/{{$.Post.ID}}">登录</a> 后参与评论
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
@ -324,7 +324,7 @@
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrfToken }
|
||||
})
|
||||
.then(function(r) {
|
||||
if (r.status === 401) { window.location.href = '/login?redirect=/posts/' + postId; return null; }
|
||||
if (r.status === 401) { window.location.href = '/auth/login?redirect=/posts/' + postId; return null; }
|
||||
return r.json();
|
||||
})
|
||||
.then(function(d) {
|
||||
@ -346,7 +346,7 @@
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrfToken }
|
||||
})
|
||||
.then(function(r) {
|
||||
if (r.status === 401) { window.location.href = '/login?redirect=/posts/' + postId; return null; }
|
||||
if (r.status === 401) { window.location.href = '/auth/login?redirect=/posts/' + postId; return null; }
|
||||
return r.json();
|
||||
})
|
||||
.then(function(d) {
|
||||
@ -388,7 +388,7 @@
|
||||
if (csrfToken) opts.headers['X-CSRF-Token'] = csrfToken;
|
||||
if (data) opts.body = JSON.stringify(data);
|
||||
return fetch(url, opts).then(function(r) {
|
||||
if (r.status === 401) { window.location.href = '/login?redirect=/posts/' + postId; throw new Error('unauthorized'); }
|
||||
if (r.status === 401) { window.location.href = '/auth/login?redirect=/posts/' + postId; throw new Error('unauthorized'); }
|
||||
return r.json();
|
||||
});
|
||||
}
|
||||
@ -470,7 +470,7 @@
|
||||
// 无弹窗回退(未登录跳转)
|
||||
function handleNoModal() {
|
||||
if (!csrfToken) {
|
||||
window.location.href = '/login?redirect=/posts/' + postId;
|
||||
window.location.href = '/auth/login?redirect=/posts/' + postId;
|
||||
return;
|
||||
}
|
||||
// 无弹窗兜底:直接 toggle
|
||||
@ -571,7 +571,7 @@
|
||||
|
||||
// 事件:点击收藏按钮 → 打开弹窗
|
||||
favBtn.addEventListener('click', function() {
|
||||
if (!csrfToken) { window.location.href = '/login?redirect=/posts/' + postId; return; }
|
||||
if (!csrfToken) { window.location.href = '/auth/login?redirect=/posts/' + postId; return; }
|
||||
showModal();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user