refactor: 删除冗余常量文件并整合常量定义

This commit is contained in:
TsMask
2025-02-20 09:50:29 +08:00
parent 1b435074cb
commit a1296b6fe6
63 changed files with 1823 additions and 1748 deletions

View File

@@ -0,0 +1,35 @@
package reqctx
import (
"github.com/gin-gonic/gin"
"be.ems/src/framework/ip2region"
"be.ems/src/framework/utils/ua"
)
// IPAddrLocation 解析ip地址
func IPAddrLocation(c *gin.Context) (string, string) {
ip := ip2region.ClientIP(c.ClientIP())
location := "-" //ip2region.RealAddressByIp(ip)
return ip, location
}
// UaOsBrowser 解析请求用户代理信息
func UaOsBrowser(c *gin.Context) (string, string) {
userAgent := c.GetHeader("user-agent")
uaInfo := ua.Info(userAgent)
browser := "-"
if bName, bVersion := uaInfo.Browser(); bName != "" {
browser = bName
if bVersion != "" {
browser = bName + " " + bVersion
}
}
os := "-"
if bos := uaInfo.OS(); bos != "" {
os = bos
}
return os, browser
}