优化页面、修复BUG

This commit is contained in:
李琦
2026-06-24 16:50:04 +08:00
parent 88ba9be318
commit 3f653bc336
36 changed files with 1672 additions and 2401 deletions

17
server/utils/visitor.go Normal file
View File

@@ -0,0 +1,17 @@
package utils
import (
"github.com/gin-gonic/gin"
"github.com/google/uuid"
)
// GetOrSetVisitorID returns an anonymous visitor identifier from cookie, creating one if missing.
func GetOrSetVisitorID(c *gin.Context) string {
if cookie, err := c.Cookie("visitor_id"); err == nil && cookie != "" {
return cookie
}
id := uuid.New().String()
c.SetCookie("visitor_id", id, 365*24*3600, "/", "", false, true)
return id
}