feat(widget): 优化访客在线轨迹、GeoIP与多站点渠道
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"kefu-cloud/server/internal/config"
|
||||
"kefu-cloud/server/internal/geoip"
|
||||
"kefu-cloud/server/internal/handler"
|
||||
"kefu-cloud/server/internal/metrics"
|
||||
"kefu-cloud/server/internal/middleware"
|
||||
@@ -22,6 +23,14 @@ func main() {
|
||||
// 初始化数据库
|
||||
model.InitDB(cfg.Database.DSN())
|
||||
|
||||
// 可选 GeoIP 离线库;未配置或文件不存在时自动降级到 CDN 国家头/未知。
|
||||
if err := geoip.Init(cfg.GeoIP.DBPath); err != nil {
|
||||
log.Printf("警告: GeoIP 数据库未启用: %v", err)
|
||||
} else if geoip.Enabled() {
|
||||
log.Printf("GeoIP 数据库已启用: %s", cfg.GeoIP.DBPath)
|
||||
defer geoip.Close()
|
||||
}
|
||||
|
||||
// 初始化 JWT(有效期可用 JWT_EXPIRE_HOURS 配置,默认 24 小时)
|
||||
middleware.InitJWT(cfg.JWT.Secret, cfg.JWT.ExpireTime)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user