fix: 修复登录重定向失效 + 404页面友好化

- ShowPage 未登录用户看未发布帖子时引导登录(携带 redirect 参数),替代直接 404
- login.js 无 redirect 参数时回退到同站 Referer 页面
- 404 页面重设计:SVG 图标 + 中文提示 + 返回首页和浏览帖子双按钮
- posts.css 新增 404 页面按钮样式
This commit is contained in:
2026-05-31 03:39:18 +08:00
parent 8b075f7387
commit e1fb28e8fb
4 changed files with 84 additions and 10 deletions

View File

@ -95,6 +95,11 @@ func (ctrl *PostController) ShowPage(c *gin.Context) {
// 仅 approved 公开可见(作者本人 + moderator+ 可预览其他状态)
if post.Status != model.PostStatusApproved && !ctrl.postService.IsPostAccessible(uid, role, post.UserID) {
// 未登录用户:引导登录后回到当前帖子
if uid == 0 {
common.RedirectToLogin(c)
return
}
c.HTML(http.StatusNotFound, "posts/404.html", common.BuildPageData(c, gin.H{
"Title": "未找到",
}))