🎨 Improve detecting Pad device, treat it as desktop device https://github.com/siyuan-note/siyuan/issues/8435

This commit is contained in:
Daniel 2023-06-02 08:58:30 +08:00
parent b94c1c66d4
commit d6cbafe11f
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -195,7 +195,7 @@ func serveAppearance(ginServer *gin.Engine) {
siyuan := ginServer.Group("", model.CheckAuth)
siyuan.Handle("GET", "/", func(c *gin.Context) {
userAgentHeader := c.GetHeader("User-Agent")
userAgentHeaderLower := strings.ToLower(c.GetHeader("User-Agent"))
/* Carry query parameters when redirecting */
location := url.URL{}
@ -203,17 +203,15 @@ func serveAppearance(ginServer *gin.Engine) {
queryParams.Set("r", gulu.Rand.String(7))
location.RawQuery = queryParams.Encode()
if strings.Contains(userAgentHeader, "Electron") {
if strings.Contains(userAgentHeaderLower, "electron") {
location.Path = "/stage/build/app/"
} else if strings.Contains(userAgentHeaderLower, "pad") {
// Improve detecting Pad device, treat it as desktop device https://github.com/siyuan-note/siyuan/issues/8435
location.Path = "/stage/build/desktop/"
} else {
ua := useragent.New(userAgentHeader)
ua := useragent.New(userAgentHeaderLower)
if ua.Mobile() {
if strings.Contains(strings.ToLower(ua.Platform()), "pad") {
// Improve detecting Pad device, treat it as desktop device https://github.com/siyuan-note/siyuan/issues/8435
location.Path = "/stage/build/desktop/"
} else {
location.Path = "/stage/build/mobile/"
}
location.Path = "/stage/build/mobile/"
} else {
location.Path = "/stage/build/desktop/"
}