node build fixed
This commit is contained in:
48
seanime-2.9.10/internal/util/useragent.go
Normal file
48
seanime-2.9.10/internal/util/useragent.go
Normal 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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user