🎨 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
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"syncPerception": "Sync perception",
|
||||
"syncPerceptionTip": "After enabling, it will automatically receive and send data sync signals, so that data sync can be performed for all online devices as much as possible in real time (this feature is currently in the experimental stage)",
|
||||
"hide": "Hide",
|
||||
"wrap": "Wrap column",
|
||||
"edit": "Edit",
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"syncPerception": "Percepción de sincronización",
|
||||
"syncPerceptionTip": "Después de habilitarlo, automáticamente recibirá y enviará señales de sincronización de datos, de modo que la sincronización de datos se pueda realizar para todos los dispositivos en línea tanto como sea posible en tiempo real (esta función se encuentra actualmente en etapa experimental)",
|
||||
"hide": "Ocultar",
|
||||
"wrap": "Columna de ajuste",
|
||||
"edit": "Editar",
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"syncPerception": "Perception de la synchronisation",
|
||||
"syncPerceptionTip": "Après l'activation, il recevra et enverra automatiquement des signaux de synchronisation des données, afin que la synchronisation des données puisse être effectuée pour tous les appareils en ligne autant que possible en temps réel (cette fonctionnalité est actuellement en phase expérimentale)",
|
||||
"hide": "Masquer",
|
||||
"wrap": "Reboucler la colonne",
|
||||
"edit": "Modifier",
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"syncPerception": "同步感知",
|
||||
"syncPerceptionTip": "啟用後將自動接收和發送數據同步信號,這樣可以盡量實時地為所有在線設備進行數據同步(該特性目前處於實驗階段)",
|
||||
"hide": "隱藏",
|
||||
"wrap": "換行",
|
||||
"edit": "編輯",
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"syncPerception": "同步感知",
|
||||
"syncPerceptionTip": "启用后将自动接收和发送数据同步信号,这样可以尽量实时地为所有在线设备进行数据同步(该特性目前处于实验阶段)",
|
||||
"hide": "隐藏",
|
||||
"wrap": "换行",
|
||||
"edit": "编辑",
|
||||
|
|
|
@ -307,6 +307,14 @@ export const repos = {
|
|||
<option value="3" ${window.siyuan.config.sync.mode === 3 ? "selected" : ""}>${window.siyuan.languages.syncMode3}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="fn__flex b3-label">
|
||||
<div class="fn__flex-1">
|
||||
${window.siyuan.languages.syncPerception}
|
||||
<div class="b3-label__text">${window.siyuan.languages.syncPerceptionTip}</div>
|
||||
</div>
|
||||
<span class="fn__space"></span>
|
||||
<input type="checkbox" id="syncPerception"${window.siyuan.config.sync.perception ? " checked='checked'" : ""} class="b3-switch fn__flex-center">
|
||||
</label>
|
||||
<div class="b3-label">
|
||||
<label class="fn__flex config__item">
|
||||
<div class="fn__flex-center">${window.siyuan.languages.cloudSyncDir}</div>
|
||||
|
@ -337,6 +345,13 @@ export const repos = {
|
|||
processSync();
|
||||
});
|
||||
});
|
||||
const syncPerceptionElement = repos.element.querySelector("#syncPerception") as HTMLInputElement;
|
||||
syncPerceptionElement.addEventListener("change", () => {
|
||||
fetchPost("/api/sync/setSyncPerception", {enabled: syncPerceptionElement.checked}, () => {
|
||||
window.siyuan.config.sync.perception = syncPerceptionElement.checked;
|
||||
processSync();
|
||||
});
|
||||
});
|
||||
const switchConflictElement = repos.element.querySelector("#generateConflictDoc") as HTMLInputElement;
|
||||
switchConflictElement.addEventListener("change", () => {
|
||||
fetchPost("/api/sync/setSyncGenerateConflictDoc", {enabled: switchConflictElement.checked}, () => {
|
||||
|
|
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
@ -519,6 +519,7 @@ interface IConfig {
|
|||
sync: {
|
||||
generateConflictDoc: boolean
|
||||
enabled: boolean
|
||||
perception: boolean
|
||||
mode: number
|
||||
synced: number
|
||||
stat: string
|
||||
|
|
|
@ -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
Reference in a new issue