🎨 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-01 22:10:14 +08:00
parent 697462e306
commit 1d1661167d
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
8 changed files with 39 additions and 32 deletions

View file

@ -36,7 +36,7 @@ import (
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/cookie"
"github.com/gin-gonic/gin"
"github.com/mssola/user_agent"
"github.com/mssola/useragent"
"github.com/olahol/melody"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/api"
@ -205,10 +205,17 @@ func serveAppearance(ginServer *gin.Engine) {
if strings.Contains(userAgentHeader, "Electron") {
location.Path = "/stage/build/app/"
} else if user_agent.New(userAgentHeader).Mobile() {
location.Path = "/stage/build/mobile/"
} else {
location.Path = "/stage/build/desktop/"
ua := useragent.New(userAgentHeader)
if ua.Mobile() {
if strings.Contains(strings.ToLower(ua.Platform()), "pad") {
location.Path = "/stage/build/desktop/"
} else {
location.Path = "/stage/build/mobile/"
}
} else {
location.Path = "/stage/build/desktop/"
}
}
c.Redirect(302, location.String())