feat: 新增站点公告系统与多项体验优化
此提交完成了以下核心功能与优化: 1. 新增站点公告全流程支持:包含公告模型、CRUD接口、管理后台页面、公告详情页与首页展示 2. 实现评论楼层化与回复嵌套:重构评论系统为树状结构,支持回复评论与层级限制 3. 添加用户在线状态追踪:异步更新用户最后活跃时间并做SQL限频 4. 优化用户体验:移动端浮动操作条、统一板块标签样式、用户页签到积分展示、注册即登录优化 5. 其他细节优化:SEO站点地图新增公告页、评论分页与统计、登录/注册表单增强等
This commit is contained in:
15
backend/service/presence.go
Normal file
15
backend/service/presence.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package service
|
||||
|
||||
import "time"
|
||||
|
||||
// TouchLastSeen 更新用户最近活跃时间(在线统计)。
|
||||
// SQL 条件限频:每用户每 60 秒最多真正写一次,其余为命中 0 行的空更新;
|
||||
// 调用方以 goroutine 异步触发,不增加请求链路延迟。
|
||||
func (s *AuthService) TouchLastSeen(userID uint) {
|
||||
threshold := time.Now().Add(-time.Minute)
|
||||
_ = s.db.Exec(
|
||||
`UPDATE users SET last_seen_at = NOW()
|
||||
WHERE id = ? AND (last_seen_at IS NULL OR last_seen_at < ?)`,
|
||||
userID, threshold,
|
||||
).Error
|
||||
}
|
||||
Reference in New Issue
Block a user