Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
f821e0284b
11 changed files with 77 additions and 0 deletions
|
@ -173,6 +173,10 @@
|
|||
"setEmojiTip": "Please go to [Settings - Appearance to add emoji]",
|
||||
"openSyncTip1": "Enable cloud sync",
|
||||
"openSyncTip2": "When changing from disabled to enabled, it is recommended to manually click the sync button to trigger a synchronization",
|
||||
"syncMode": "Cloud sync mode",
|
||||
"syncModeTip": "The sync mode can be further selected after cloud sync is enabled",
|
||||
"syncMode1": "Auto (sync every 30 seconds after the data no longer changes)",
|
||||
"syncMode2": "Manual (automatic auto only once when the software is started and closed, other times need to manually trigger)",
|
||||
"cloudSync": "Cloud sync",
|
||||
"cloudSyncDir": "Cloud Sync Dir",
|
||||
"emptyCloudSyncList": "The cloud sync list is empty",
|
||||
|
|
|
@ -173,6 +173,10 @@
|
|||
"setEmojiTip": "Veuillez aller dans [Paramètres - Apparence] pour ajouter des emoji",
|
||||
"openSyncTip1": "Activer Cloud Sync",
|
||||
"openSyncTip2": "Lorsque vous passez de la désactivation à l'activation, il est recommandé de cliquer manuellement sur le bouton de synchronisation pour déclencher une synchronisation",
|
||||
"syncMode": "Mode de synchronisation cloud",
|
||||
"syncModeTip": "Le mode de synchronisation peut être sélectionné davantage après l'activation de la synchronisation dans le cloud",
|
||||
"syncMode1": "Automatique (synchronisation toutes les 30 secondes après que les données ne changent plus)",
|
||||
"syncMode2": "Manuelle (synchronisation automatique une seule fois lorsque le logiciel est démarré et fermé, les autres fois, il faut déclencher manuellement la synchronisation)",
|
||||
"cloudSync": "Cloud Sync",
|
||||
"cloudSyncDir": "Répertoire Cloud Sync",
|
||||
"emptyCloudSyncList": "La liste de sync du cloud est videy",
|
||||
|
|
|
@ -173,6 +173,10 @@
|
|||
"setEmojiTip": "請在 [設置 - 外觀] 中新增自訂表情",
|
||||
"openSyncTip1": "啟用雲端同步",
|
||||
"openSyncTip2": "從禁用改為啟用時建議手動點擊同步按鈕觸發一次同步",
|
||||
"syncMode": "雲端同步模式",
|
||||
"syncModeTip": "啟用雲端同步後可進一步選擇同步模式",
|
||||
"syncMode1": "自動同步(數據不再變動後 30 秒進行一次同步)",
|
||||
"syncMode2": "手動同步(僅啟動和關閉軟件時自動同步一次,其他時候需要手動觸發同步)",
|
||||
"cloudSync": "雲端同步",
|
||||
"cloudSyncDir": "雲端同步目錄",
|
||||
"emptyCloudSyncList": "雲端同步列表為空",
|
||||
|
|
|
@ -173,6 +173,10 @@
|
|||
"setEmojiTip": "请在 [设置 - 外观] 中添加自定义表情",
|
||||
"openSyncTip1": "启用云端同步",
|
||||
"openSyncTip2": "从禁用改为启用时建议手动点击同步按钮触发一次同步",
|
||||
"syncMode": "云端同步模式",
|
||||
"syncModeTip": "启用云端同步后可进一步选择同步模式",
|
||||
"syncMode1": "自动同步(数据不再变动后 30 秒进行一次同步)",
|
||||
"syncMode2": "手动同步(仅启动和关闭软件时自动同步一次,其他时候需要手动触发同步)",
|
||||
"cloudSync": "云端同步",
|
||||
"cloudSyncDir": "云端同步目录",
|
||||
"emptyCloudSyncList": "云端同步列表为空",
|
||||
|
|
|
@ -325,6 +325,17 @@ ${passwordHTML}
|
|||
<span class="fn__space"></span>
|
||||
<input type="checkbox" id="reposCloudSyncSwitch"${window.siyuan.config.sync.enabled ? " checked='checked'" : ""} class="b3-switch fn__flex-center">
|
||||
</label>
|
||||
<label class="fn__flex b3-label">
|
||||
<div class="fn__flex-1">
|
||||
${window.siyuan.languages.syncMode}
|
||||
<div class="b3-label__text">${window.siyuan.languages.syncModeTip}</div>
|
||||
</div>
|
||||
<span class="fn__space"></span>
|
||||
<select id="syncMode" class="b3-select fn__flex-center fn__size200">
|
||||
<option value="1" ${window.siyuan.config.sync.mode === 1 ? "selected" : ""}>${window.siyuan.languages.syncMode1}</option>
|
||||
<option value="2" ${window.siyuan.config.sync.mode === 2 ? "selected" : ""}>${window.siyuan.languages.syncMode2}</option>
|
||||
</select>
|
||||
</label>
|
||||
<div class="b3-label">
|
||||
<div class="fn__flex">
|
||||
<div class="fn__flex-center">${window.siyuan.languages.cloudSync}</div>
|
||||
|
@ -362,6 +373,17 @@ ${passwordHTML}
|
|||
}
|
||||
});
|
||||
});
|
||||
const syncModeElement = repos.element.querySelector("#syncMode") as HTMLSelectElement;
|
||||
syncModeElement.addEventListener("change", () => {
|
||||
fetchPost("/api/sync/setSyncMode", {mode: parseInt(syncModeElement.value, 10)}, (response) => {
|
||||
if (response.code === 1) {
|
||||
showMessage(response.msg);
|
||||
syncModeElement.value = "1";
|
||||
} else {
|
||||
window.siyuan.config.sync.mode = parseInt(syncModeElement.value, 10);
|
||||
}
|
||||
});
|
||||
});
|
||||
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
|
@ -242,6 +242,7 @@ declare interface IConfig {
|
|||
e2eePasswdMode: number
|
||||
sync: {
|
||||
enabled: boolean
|
||||
mode: number
|
||||
synced: number
|
||||
stat: string
|
||||
interval: number
|
||||
|
|
|
@ -163,6 +163,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/setSyncMode", model.CheckAuth, setSyncMode)
|
||||
ginServer.Handle("POST", "/api/sync/setCloudSyncDir", model.CheckAuth, setCloudSyncDir)
|
||||
ginServer.Handle("POST", "/api/sync/createCloudSyncDir", model.CheckAuth, model.CheckReadonly, createCloudSyncDir)
|
||||
ginServer.Handle("POST", "/api/sync/removeCloudSyncDir", model.CheckAuth, model.CheckReadonly, removeCloudSyncDir)
|
||||
|
|
|
@ -140,6 +140,25 @@ func setSyncEnable(c *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
func setSyncMode(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
mode := int(arg["mode"].(float64))
|
||||
err := model.SetSyncMode(mode)
|
||||
if nil != err {
|
||||
ret.Code = 1
|
||||
ret.Msg = err.Error()
|
||||
ret.Data = map[string]interface{}{"closeTimeout": 5000}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func setCloudSyncDir(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
type Sync struct {
|
||||
CloudName string `json:"cloudName"` // 云端同步目录名称
|
||||
Enabled bool `json:"enabled"` // 是否开启同步
|
||||
Mode int `json:"mode"` // 同步模式,0:未设置(为兼容已有配置,initConf 函数中会转换为 1),1:自动,2:手动 https://github.com/siyuan-note/siyuan/issues/5089
|
||||
Uploaded int64 `json:"uploaded"` // 最近上传时间
|
||||
Downloaded int64 `json:"downloaded"` // 最近下载时间
|
||||
Synced int64 `json:"synced"` // 最近同步时间
|
||||
|
@ -35,6 +36,7 @@ func NewSync() *Sync {
|
|||
return &Sync{
|
||||
CloudName: "main",
|
||||
Enabled: true,
|
||||
Mode: 1,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -214,6 +214,9 @@ func InitConf() {
|
|||
util.LogErrorf("create sync dir [%s] failed: %s", Conf.Sync.GetSaveDir(), err)
|
||||
}
|
||||
}
|
||||
if 0 == Conf.Sync.Mode {
|
||||
Conf.Sync.Mode = 1
|
||||
}
|
||||
|
||||
if nil == Conf.Api {
|
||||
Conf.Api = conf.NewAPI()
|
||||
|
|
|
@ -68,6 +68,10 @@ func AutoSync() {
|
|||
func SyncData(boot, exit, byHand bool) {
|
||||
defer util.Recover()
|
||||
|
||||
if !boot && !exit && 2 == Conf.Sync.Mode && !byHand {
|
||||
return
|
||||
}
|
||||
|
||||
if util.IsMutexLocked(&syncLock) {
|
||||
util.LogWarnf("sync has been locked")
|
||||
syncInterval = 30 * time.Second
|
||||
|
@ -513,6 +517,15 @@ func SetSyncEnable(b bool) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func SetSyncMode(mode int) (err error) {
|
||||
syncLock.Lock()
|
||||
defer syncLock.Unlock()
|
||||
|
||||
Conf.Sync.Mode = mode
|
||||
Conf.Save()
|
||||
return
|
||||
}
|
||||
|
||||
var syncLock = sync.Mutex{}
|
||||
|
||||
func syncDirUpsertWorkspaceData(downloadedFiles []string) (err error) {
|
||||
|
|
Loading…
Add table
Reference in a new issue