feat: 新增站点公告系统与多项体验优化

此提交完成了以下核心功能与优化:
1. 新增站点公告全流程支持:包含公告模型、CRUD接口、管理后台页面、公告详情页与首页展示
2. 实现评论楼层化与回复嵌套:重构评论系统为树状结构,支持回复评论与层级限制
3. 添加用户在线状态追踪:异步更新用户最后活跃时间并做SQL限频
4. 优化用户体验:移动端浮动操作条、统一板块标签样式、用户页签到积分展示、注册即登录优化
5. 其他细节优化:SEO站点地图新增公告页、评论分页与统计、登录/注册表单增强等
This commit is contained in:
2026-09-13 21:38:01 +08:00
parent 9bae6f2513
commit 996a870015
41 changed files with 2846 additions and 786 deletions

View File

@@ -31,7 +31,12 @@ export default function RegisterPage() {
setLoading(true);
try {
const res = await apiRegister(username, email, password);
if (res.id) {
if (res.user) {
// 后端注册即签发登录态 cookie:直接进入社区,无需再手动登录
router.push("/");
router.refresh();
} else if (res.id) {
// 极端情况:注册成功但自动签发失败,引导去登录
router.push("/login");
} else {
setError(res.error || "注册失败");
@@ -59,10 +64,11 @@ export default function RegisterPage() {
</div>
<form onSubmit={handleSubmit} className="panel p-6 sm:p-7 space-y-4">
{error && <div className="alert-error">{error}</div>}
{error && <div className="alert-error" role="alert">{error}</div>}
<div>
<label className="field-label">用户名</label>
<label className="field-label" htmlFor="reg-username">用户名</label>
<input
id="reg-username"
type="text"
value={username}
onChange={(e) => setUsername(e.target.value)}
@@ -70,28 +76,33 @@ export default function RegisterPage() {
minLength={3}
maxLength={32}
autoFocus
autoComplete="username"
className="field"
placeholder="3–32 位"
/>
</div>
<div>
<label className="field-label">邮箱(可选)</label>
<label className="field-label" htmlFor="reg-email">邮箱(可选)</label>
<input
id="reg-email"
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
autoComplete="email"
className="field"
placeholder="you@example.com"
/>
</div>
<div>
<label className="field-label">密码</label>
<label className="field-label" htmlFor="reg-password">密码</label>
<input
id="reg-password"
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
required
minLength={6}
autoComplete="new-password"
className="field"
placeholder="至少 6 位"
/>