From 61c57c9c30bef716c28de0eefb8dc60a1f966c2a Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 20 Jan 2023 11:49:46 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20Android=20=E7=AB=AF=E5=89=8D=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E5=88=87=E6=8D=A2=E6=97=B6=E8=87=AA=E5=8A=A8=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E5=90=8C=E6=AD=A5=20=20https://github.com/siyuan-note?= =?UTF-8?q?/siyuan/issues/7122?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/api/sync.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/kernel/api/sync.go b/kernel/api/sync.go index 1e3a644fd..4b04c6cce 100644 --- a/kernel/api/sync.go +++ b/kernel/api/sync.go @@ -40,6 +40,23 @@ func getBootSync(c *gin.Context) { func performSync(c *gin.Context) { ret := gulu.Ret.NewResult() defer c.JSON(http.StatusOK, ret) + + arg, ok := util.JsonArg(c, ret) + if !ok { + return + } + + // Android 端前后台切换时自动触发同步 https://github.com/siyuan-note/siyuan/issues/7122 + var mobileSwitch bool + if mobileSwitchArg := arg["mobileSwitch"]; nil != mobileSwitchArg { + mobileSwitch = mobileSwitchArg.(bool) + } + if mobileSwitch { + if nil == model.Conf.User || !model.Conf.Sync.Enabled { + return + } + } + model.SyncData(false, false, true) }