mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-10 09:14:20 +01:00
🎨 Data synchronization supports the multi-kernel online perception https://github.com/siyuan-note/siyuan/issues/8518
This commit is contained in:
parent
ae336e9f36
commit
f7818c54b1
11 changed files with 48 additions and 0 deletions
|
|
@ -196,6 +196,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/cloud/getCloudSpace", model.CheckAuth, getCloudSpace)
|
||||
|
||||
ginServer.Handle("POST", "/api/sync/setSyncEnable", model.CheckAuth, model.CheckReadonly, setSyncEnable)
|
||||
ginServer.Handle("POST", "/api/sync/setSyncPerception", model.CheckAuth, model.CheckReadonly, setSyncPerception)
|
||||
ginServer.Handle("POST", "/api/sync/setSyncGenerateConflictDoc", model.CheckAuth, model.CheckReadonly, setSyncGenerateConflictDoc)
|
||||
ginServer.Handle("POST", "/api/sync/setSyncMode", model.CheckAuth, model.CheckReadonly, setSyncMode)
|
||||
ginServer.Handle("POST", "/api/sync/setSyncProvider", model.CheckAuth, model.CheckReadonly, setSyncProvider)
|
||||
|
|
|
|||
|
|
@ -169,6 +169,19 @@ func setSyncEnable(c *gin.Context) {
|
|||
model.SetSyncEnable(enabled)
|
||||
}
|
||||
|
||||
func setSyncPerception(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
enabled := arg["enabled"].(bool)
|
||||
model.SetSyncPerception(enabled)
|
||||
}
|
||||
|
||||
func setSyncMode(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package conf
|
|||
type Sync struct {
|
||||
CloudName string `json:"cloudName"` // 云端同步目录名称
|
||||
Enabled bool `json:"enabled"` // 是否开启同步
|
||||
Perception bool `json:"perception"` // 是否开启感知
|
||||
Mode int `json:"mode"` // 同步模式,0:未设置(为兼容已有配置,initConf 函数中会转换为 1),1:自动,2:手动 https://github.com/siyuan-note/siyuan/issues/5089,3:完全手动 https://github.com/siyuan-note/siyuan/issues/7295
|
||||
Synced int64 `json:"synced"` // 最近同步时间
|
||||
Stat string `json:"stat"` // 最近同步统计信息
|
||||
|
|
@ -32,6 +33,7 @@ func NewSync() *Sync {
|
|||
return &Sync{
|
||||
CloudName: "main",
|
||||
Enabled: false,
|
||||
Perception: false,
|
||||
Mode: 1,
|
||||
GenerateConflictDoc: false,
|
||||
Provider: ProviderSiYuan,
|
||||
|
|
|
|||
|
|
@ -369,6 +369,12 @@ func SetSyncEnable(b bool) {
|
|||
return
|
||||
}
|
||||
|
||||
func SetSyncPerception(b bool) {
|
||||
Conf.Sync.Perception = b
|
||||
Conf.Save()
|
||||
return
|
||||
}
|
||||
|
||||
func SetSyncMode(mode int) (err error) {
|
||||
Conf.Sync.Mode = mode
|
||||
Conf.Save()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue