node build fixed

This commit is contained in:
ra_ma
2025-09-20 14:08:38 +01:00
parent c6ebbe069d
commit 3d298fa434
1516 changed files with 535727 additions and 2 deletions

View File

@@ -0,0 +1,48 @@
package util
import "github.com/mileusna/useragent"
const (
PlatformAndroid = "android"
PlatformIOS = "ios"
PlatformLinux = "linux"
PlatformMac = "mac"
PlatformWindows = "windows"
PlatformChromeOS = "chromeos"
)
const (
DeviceDesktop = "desktop"
DeviceMobile = "mobile"
DeviceTablet = "tablet"
)
type ClientInfo struct {
Device string
Platform string
}
func GetClientInfo(userAgent string) ClientInfo {
ua := useragent.Parse(userAgent)
var device string
var platform string
if ua.Mobile {
device = DeviceMobile
} else if ua.Tablet {
device = DeviceTablet
} else {
device = DeviceDesktop
}
platform = ua.OS
if platform == "" {
platform = "-"
}
return ClientInfo{
Device: device,
Platform: platform,
}
}