Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Android 端前后台切换时自动触发同步 https://github.com/siyuan-note/siyuan/issues/7122

Liang Ding61c57c9c30be
diff --git a/kernel/api/sync.go b/kernel/api/sync.go
index 1e3a644fde..4b04c6cce2 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)
}