Skip to content

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

:art: Improve the mouse hove data sync button information on the desktop and browser https://github.com/siyuan-note/siyuan/issues/8521

Danielb53d2102586d
diff --git a/kernel/api/router.go b/kernel/api/router.go
index e2f0dd3c66..592f72e44b 100644
--- a/kernel/api/router.go
+++ b/kernel/api/router.go
@@ -209,6 +209,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/sync/performSync", model.CheckAuth, model.CheckReadonly, performSync)
ginServer.Handle("POST", "/api/sync/performBootSync", model.CheckAuth, model.CheckReadonly, performBootSync)
ginServer.Handle("POST", "/api/sync/getBootSync", model.CheckAuth, getBootSync)
+ ginServer.Handle("POST", "/api/sync/getSyncInfo", model.CheckAuth, getSyncInfo)
ginServer.Handle("POST", "/api/inbox/getShorthands", model.CheckAuth, getShorthands)
ginServer.Handle("POST", "/api/inbox/getShorthand", model.CheckAuth, getShorthand)
diff --git a/kernel/api/sync.go b/kernel/api/sync.go
index 115ab3b470..9c1a8c25df 100644
--- a/kernel/api/sync.go
+++ b/kernel/api/sync.go
@@ -26,6 +26,22 @@ import (
"github.com/siyuan-note/siyuan/kernel/util"
)
+func getSyncInfo(c *gin.Context) {
+ ret := gulu.Ret.NewResult()
+ defer c.JSON(http.StatusOK, ret)
+
+ if !model.Conf.Sync.Enabled {
+ ret.Msg = model.Conf.Language(53)
+ return
+ }
+
+ ret.Data = map[string]interface{}{
+ "synced": model.Conf.Sync.Synced,
+ "stat": model.Conf.Sync.Stat,
+ "kernels": model.GetOnlineKernels(),
+ }
+}
+
func getBootSync(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
diff --git a/kernel/model/sync.go b/kernel/model/sync.go
index b6732ef5cf..3b782f2c08 100644
--- a/kernel/model/sync.go
+++ b/kernel/model/sync.go
@@ -653,6 +653,12 @@ var (
onlineKernelsLock = sync.Mutex{}
)
+func GetOnlineKernels() []*OnlineKernel {
+ onlineKernelsLock.Lock()
+ defer onlineKernelsLock.Unlock()
+ return onlineKernels
+}
+
var closedSyncWebSocket = false
func closeSyncWebSocket() {