mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-02 21:19:47 +08:00
🎨 公测云端同步数据仓库 https://github.com/siyuan-note/siyuan/issues/5337
This commit is contained in:
parent
5b1b38aabe
commit
eb79fbd37d
@ -1,4 +1,6 @@
|
||||
{
|
||||
"syncDataRepo": "⏰ Use data repo sync mechanism",
|
||||
"syncDataRepoTip": "The data repo sync mechanism will be used in the upcoming v2.1.0, the existing sync mechanism will be offline",
|
||||
"dataRepo": "Data repo",
|
||||
"newSubDoc": "Create sub doc",
|
||||
"newDocBelow": "Create doc below",
|
||||
|
@ -1,4 +1,6 @@
|
||||
{
|
||||
"syncDataRepo": "⏰ Usar mecanismo de sincronización de repositorio de datos",
|
||||
"syncDataRepoTip": "El mecanismo de sincronización del repositorio de datos se usará en la próxima v2.1.0, el mecanismo de sincronización existente estará fuera de línea",
|
||||
"dataRepo": "Repositorio de datos",
|
||||
"newSubDoc": "Crear subdocumento",
|
||||
"newDocBelow": "Crear documento a continuación",
|
||||
|
@ -1,4 +1,6 @@
|
||||
{
|
||||
"syncDataRepo": "⏰ Utiliser le mécanisme de synchronisation du référentiel de données",
|
||||
"syncDataRepoTip": "Le mécanisme de synchronisation du référentiel de données sera utilisé dans la prochaine v2.1.0, le mécanisme de synchronisation existant sera hors ligne",
|
||||
"dataRepo": "Dépôt de données",
|
||||
"newSubDoc": "Créer un sous-doc",
|
||||
"newDocBelow": "Créer un document ci-dessous",
|
||||
|
@ -1,4 +1,6 @@
|
||||
{
|
||||
"syncDataRepo": "⏰ 使用數據倉庫同步機制",
|
||||
"syncDataRepoTip": "在即將到來的 v2.1.0 版本將使用數據倉庫同步機制,屆時現有的同步機制會下線",
|
||||
"dataRepo": "數據倉庫",
|
||||
"newSubDoc": "新建子文檔",
|
||||
"newDocBelow": "在下方新建文檔",
|
||||
|
@ -1,4 +1,6 @@
|
||||
{
|
||||
"syncDataRepo": "⏰ 使用数据仓库同步机制",
|
||||
"syncDataRepoTip": "在即将到来的 v2.1.0 版本将使用数据仓库同步机制,届时现有的同步机制会下线",
|
||||
"dataRepo": "数据仓库",
|
||||
"newSubDoc": "新建子文档",
|
||||
"newDocBelow": "在下方新建文档",
|
||||
|
@ -361,6 +361,14 @@ ${passwordHTML}
|
||||
<option value="2" ${window.siyuan.config.sync.mode === 2 ? "selected" : ""}>${window.siyuan.languages.syncMode2}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="fn__flex b3-label">
|
||||
<div class="fn__flex-1">
|
||||
${window.siyuan.languages.syncDataRepo}
|
||||
<div class="b3-label__text">${window.siyuan.languages.syncDataRepoTip}</div>
|
||||
</div>
|
||||
<span class="fn__space"></span>
|
||||
<input type="checkbox" id="useDataRepo"${window.siyuan.config.sync.useDataRepo ? " checked='checked'" : ""} class="b3-switch fn__flex-center">
|
||||
</label>
|
||||
<div class="b3-label">
|
||||
<div class="fn__flex">
|
||||
<div class="fn__flex-center">${window.siyuan.languages.cloudSync}</div>
|
||||
@ -409,6 +417,17 @@ ${passwordHTML}
|
||||
}
|
||||
});
|
||||
});
|
||||
const useDataRepoElement = repos.element.querySelector("#useDataRepo") as HTMLInputElement;
|
||||
useDataRepoElement.addEventListener("change", () => {
|
||||
fetchPost("/api/sync/setSyncUseDataRepo", {enabled: useDataRepoElement.checked}, (response) => {
|
||||
if (response.code === 1) {
|
||||
showMessage(response.msg);
|
||||
useDataRepoElement.checked = false;
|
||||
} else {
|
||||
window.siyuan.config.sync.useDataRepo = useDataRepoElement.checked;
|
||||
}
|
||||
});
|
||||
});
|
||||
const loadingElement = repos.element.querySelector("#reposLoading") as HTMLElement;
|
||||
loadingElement.style.width = repos.element.clientWidth + "px";
|
||||
loadingElement.style.height = repos.element.clientHeight + "px";
|
||||
|
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
@ -255,6 +255,7 @@ declare interface IConfig {
|
||||
stat: string
|
||||
interval: number
|
||||
cloudName: string
|
||||
useDataRepo: boolean
|
||||
},
|
||||
lang: string
|
||||
api: {
|
||||
|
@ -167,6 +167,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
||||
ginServer.Handle("POST", "/api/backup/removeCloudBackup", model.CheckAuth, model.CheckReadonly, removeCloudBackup)
|
||||
|
||||
ginServer.Handle("POST", "/api/sync/setSyncEnable", model.CheckAuth, setSyncEnable)
|
||||
ginServer.Handle("POST", "/api/sync/setSyncUseDataRepo", model.CheckAuth, setSyncUseDataRepo)
|
||||
ginServer.Handle("POST", "/api/sync/setSyncMode", model.CheckAuth, setSyncMode)
|
||||
ginServer.Handle("POST", "/api/sync/setCloudSyncDir", model.CheckAuth, setCloudSyncDir)
|
||||
ginServer.Handle("POST", "/api/sync/createCloudSyncDir", model.CheckAuth, model.CheckReadonly, createCloudSyncDir)
|
||||
|
@ -121,6 +121,25 @@ func createCloudSyncDir(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func setSyncUseDataRepo(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)
|
||||
err := model.SetSyncUseDataRepo(enabled)
|
||||
if nil != err {
|
||||
ret.Code = 1
|
||||
ret.Msg = err.Error()
|
||||
ret.Data = map[string]interface{}{"closeTimeout": 5000}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func setSyncEnable(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
@ -491,6 +491,15 @@ func SetSyncEnable(b bool) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func SetSyncUseDataRepo(b bool) (err error) {
|
||||
syncLock.Lock()
|
||||
defer syncLock.Unlock()
|
||||
|
||||
Conf.Sync.UseDataRepo = b
|
||||
Conf.Save()
|
||||
return
|
||||
}
|
||||
|
||||
func SetSyncMode(mode int) (err error) {
|
||||
syncLock.Lock()
|
||||
defer syncLock.Unlock()
|
||||
|
Loading…
Reference in New Issue
Block a user