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

@ -19,6 +19,19 @@
function getRedirect() {
var m = window.location.search.match(/[?&]redirect=([^&]+)/);
if (m) return decodeURIComponent(m[1]);
// 回退:如果来源页是本站页面,跳回来源页
try {
var ref = document.referrer;
if (ref) {
var a = document.createElement('a');
a.href = ref;
if (a.hostname === window.location.hostname &&
a.pathname !== window.location.pathname &&
a.pathname.indexOf('/auth/') !== 0) {
return a.pathname + a.search + a.hash;
}
}
} catch (e) {}
return '/';
}