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

This commit is contained in:
Daniel 2023-06-12 10:37:54 +08:00
parent 71add56563
commit b53d210258
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 23 additions and 0 deletions

View file

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

View file

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

View file

@ -653,6 +653,12 @@ var (
onlineKernelsLock = sync.Mutex{}
)
func GetOnlineKernels() []*OnlineKernel {
onlineKernelsLock.Lock()
defer onlineKernelsLock.Unlock()
return onlineKernels
}
var closedSyncWebSocket = false
func closeSyncWebSocket() {