🎨 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

@ -323,7 +323,7 @@ SiYuan is made possible by the following open source projects.
* [https://github.com/jinzhu/copier](https://github.com/jinzhu/copier) `MIT License`
* [https://github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) `MIT License`
* [https://github.com/mitchellh/go-ps](https://github.com/mitchellh/go-ps) `MIT License`
* [https://github.com/mssola/user_agent](https://github.com/mssola/user_agent) `MIT License`
* [https://github.com/mssola/useragent](https://github.com/mssola/useragent) `MIT License`
* [https://github.com/panjf2000/ants](https://github.com/panjf2000/ants) `MIT License`
* [https://github.com/patrickmn/go-cache](https://github.com/patrickmn/go-cache) `MIT License`
* [https://github.com/radovskyb/watcher](https://github.com/radovskyb/watcher) `BSD-3-Clause License`

View file

@ -337,7 +337,7 @@
* [https://github.com/jinzhu/copier](https://github.com/jinzhu/copier) `MIT License`
* [https://github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) `MIT License`
* [https://github.com/mitchellh/go-ps](https://github.com/mitchellh/go-ps) `MIT License`
* [https://github.com/mssola/user_agent](https://github.com/mssola/user_agent) `MIT License`
* [https://github.com/mssola/useragent](https://github.com/mssola/useragent) `MIT License`
* [https://github.com/panjf2000/ants](https://github.com/panjf2000/ants) `MIT License`
* [https://github.com/patrickmn/go-cache](https://github.com/patrickmn/go-cache) `MIT License`
* [https://github.com/radovskyb/watcher](https://github.com/radovskyb/watcher) `BSD-3-Clause License`

View file

@ -7,7 +7,7 @@
"id": "20201121224345-rc27qvo",
"title": "Acknowledgements",
"type": "doc",
"updated": "20230329104243"
"updated": "20230601220909"
},
"Children": [
{
@ -30,7 +30,7 @@
"ListData": {},
"Properties": {
"id": "20220522101213-z3hokh2",
"updated": "20230329104243"
"updated": "20230601220909"
},
"Children": [
{
@ -1289,7 +1289,7 @@
},
"Properties": {
"id": "20220522101213-baxbnuz",
"updated": "20220522101213"
"updated": "20230601220909"
},
"Children": [
{
@ -1297,14 +1297,14 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20220522101213-zirylou",
"updated": "20220522101213"
"updated": "20230601220909"
},
"Children": [
{
"Type": "NodeTextMark",
"TextMarkType": "a",
"TextMarkAHref": "https://github.com/mssola/user_agent",
"TextMarkTextContent": "https://github.com/mssola/user_agent"
"TextMarkAHref": "https://github.com/mssola/useragent",
"TextMarkTextContent": "https://github.com/mssola/useragent"
},
{
"Type": "NodeText",
@ -1317,7 +1317,7 @@
},
{
"Type": "NodeText",
"Data": ""
"Data": ""
}
]
}

View file

@ -7,7 +7,7 @@
"id": "20201121212605-9td1a62",
"title": "致谢",
"type": "doc",
"updated": "20230329104237"
"updated": "20230601220833"
},
"Children": [
{
@ -30,7 +30,7 @@
"ListData": {},
"Properties": {
"id": "20220522101224-ctmcj3d",
"updated": "20230329104237"
"updated": "20230601220833"
},
"Children": [
{
@ -1332,7 +1332,7 @@
},
"Properties": {
"id": "20220522101224-zea3u6q",
"updated": "20220522101224"
"updated": "20230601220833"
},
"Children": [
{
@ -1340,14 +1340,14 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20220522101224-295m1cs",
"updated": "20220522101224"
"updated": "20230601220833"
},
"Children": [
{
"Type": "NodeTextMark",
"TextMarkType": "a",
"TextMarkAHref": "https://github.com/mssola/user_agent",
"TextMarkTextContent": "https://github.com/mssola/user_agent"
"TextMarkAHref": "https://github.com/mssola/useragent",
"TextMarkTextContent": "https://github.com/mssola/useragent"
},
{
"Type": "NodeText",

View file

@ -6,7 +6,7 @@
"icon": "1f64f",
"id": "20211226114929-08ap1r0",
"title": "致謝",
"updated": "20230329104241"
"updated": "20230601220854"
},
"Children": [
{
@ -29,7 +29,7 @@
"ListData": {},
"Properties": {
"id": "20220326092650-r61gazd",
"updated": "20230329104241"
"updated": "20230601220854"
},
"Children": [
{
@ -1331,7 +1331,7 @@
},
"Properties": {
"id": "20220326092650-y159g0d",
"updated": "20220326092650"
"updated": "20230601220854"
},
"Children": [
{
@ -1339,14 +1339,14 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20220326092650-9fe8vh7",
"updated": "20220326092650"
"updated": "20230601220854"
},
"Children": [
{
"Type": "NodeTextMark",
"TextMarkType": "a",
"TextMarkAHref": "https://github.com/mssola/user_agent",
"TextMarkTextContent": "https://github.com/mssola/user_agent"
"TextMarkAHref": "https://github.com/mssola/useragent",
"TextMarkTextContent": "https://github.com/mssola/useragent"
},
{
"Type": "NodeText",
@ -1359,7 +1359,7 @@
},
{
"Type": "NodeText",
"Data": ""
"Data": ""
}
]
}

View file

@ -6,7 +6,7 @@ require (
github.com/88250/clipboard v0.1.5
github.com/88250/css v0.1.2
github.com/88250/gulu v1.2.3-0.20230501031728-4d62370997cd
github.com/88250/lute v1.7.6-0.20230528141918-0435fd1d81f0
github.com/88250/lute v1.7.6-0.20230601122257-d3e47350b348
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
github.com/ClarkThan/ahocorasick v0.0.0-20230220142845-f237b6348b3e
@ -36,7 +36,7 @@ require (
github.com/json-iterator/go v1.1.12
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/mitchellh/go-ps v1.0.0
github.com/mssola/user_agent v0.6.0
github.com/mssola/useragent v1.0.0
github.com/olahol/melody v1.1.3
github.com/open-spaced-repetition/go-fsrs v0.1.1
github.com/panjf2000/ants/v2 v2.7.4

View file

@ -8,8 +8,8 @@ github.com/88250/go-sqlite3 v1.14.13-0.20220714142610-fbbda1ee84f5 h1:8HdZozCsXS
github.com/88250/go-sqlite3 v1.14.13-0.20220714142610-fbbda1ee84f5/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/88250/gulu v1.2.3-0.20230501031728-4d62370997cd h1:PgbmnoTqfVbYyhUljovnAz6l/oWPlbM1d5yrkVDHO1w=
github.com/88250/gulu v1.2.3-0.20230501031728-4d62370997cd/go.mod h1:pTWnjt+6qUqNnP9xltswsJxgCBVu3C7eW09u48LWX0k=
github.com/88250/lute v1.7.6-0.20230528141918-0435fd1d81f0 h1:M3kT6G/+CAkYjytDesKE3fGM5/HYDzJGT6oR/mD41KQ=
github.com/88250/lute v1.7.6-0.20230528141918-0435fd1d81f0/go.mod h1:+wUqx/1kdFDbWtxn9LYJlaCOAeol2pjSO6w+WJTVQsg=
github.com/88250/lute v1.7.6-0.20230601122257-d3e47350b348 h1:hozOX6EnSiOkf93eWdbVXKHL6fz7NqOjqT2cme0t7sY=
github.com/88250/lute v1.7.6-0.20230601122257-d3e47350b348/go.mod h1:+wUqx/1kdFDbWtxn9LYJlaCOAeol2pjSO6w+WJTVQsg=
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c h1:Dl/8S9iLyPMTElnWIBxmjaLiWrkI5P4a21ivwAn5pU0=
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4=
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=
@ -220,8 +220,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/mssola/user_agent v0.6.0 h1:uwPR4rtWlCHRFyyP9u2KOV0u8iQXmS7Z7feTrstQwk4=
github.com/mssola/user_agent v0.6.0/go.mod h1:TTPno8LPY3wAIEKRpAtkdMT0f8SE24pLRGPahjCH4uw=
github.com/mssola/useragent v1.0.0 h1:WRlDpXyxHDNfvZaPEut5Biveq86Ze4o4EMffyMxmH5o=
github.com/mssola/useragent v1.0.0/go.mod h1:hz9Cqz4RXusgg1EdI4Al0INR62kP7aPSRNHnpU+b85Y=
github.com/olahol/melody v1.1.3 h1:7Eo8egmejdrhdCM64uPgWj7NLSAVKl7Iv9NloFlzb60=
github.com/olahol/melody v1.1.3/go.mod h1:GgkTl6Y7yWj/HtfD48Q5vLKPVoZOH+Qqgfa7CvJgJM4=
github.com/onsi/ginkgo/v2 v2.9.7 h1:06xGQy5www2oN160RtEZoTvnP2sPhEfePYmCDc2szss=

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())