fix: 管理会话自动恢复与访问来源统计优化

- 新增 AdminSessionRecover:后台离线/后端重启时自动重试恢复会话,明确失效才回跳登录
- 认证 cookie 契约调整(SameSite=Lax 与刷新轮转适配),路由与守卫适配
- 访问来源统计查询优化与测试、管理端 analytics sources 页面适配
- 移动端布局修正:覆盖 body min-h-screen 避免内容区高度异常
This commit is contained in:
2026-09-28 03:33:52 +08:00
parent 0c3b3a710c
commit 3e0689fe98
15 changed files with 548 additions and 85 deletions

View File

@@ -8,6 +8,7 @@ import (
"net/url"
"path/filepath"
"strconv"
"strings"
"time"
"github.com/freefire/jiang13-bbs/middleware"
@@ -16,13 +17,20 @@ import (
"github.com/gin-gonic/gin"
)
// maxSearchKeywordRunes 帖子搜索关键词长度上限(字符数,与前端搜索框 maxLength 一致)
const maxSearchKeywordRunes = 100
// Posts 获取帖子列表
func (h *Handlers) Posts(c *gin.Context) {
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
size, _ := strconv.Atoi(c.DefaultQuery("size", "20"))
boardID, _ := strconv.ParseUint(c.Query("board_id"), 10, 64)
sort := c.DefaultQuery("sort", "latest")
keyword := c.Query("keyword")
keyword := strings.TrimSpace(c.Query("keyword"))
// 搜索词上限:前端输入框同限;超长词 ILIKE 必然无意义结果,静默截断
if runes := []rune(keyword); len(runes) > maxSearchKeywordRunes {
keyword = string(runes[:maxSearchKeywordRunes])
}
recommended := c.Query("recommended") == "true"
var viewerID uint