Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2024-12-14 12:08:17 +08:00
commit 775efe6a8e
18 changed files with 100 additions and 12 deletions

View file

@ -1,4 +1,6 @@
{
"second": "Sekunde",
"syncInterval": "Synchronisierungsintervall",
"removeAV": "Aus der Datenbank entfernen",
"empty": "Leer",
"newRowInRelation": "Erstellen Sie einen neuen Eintrag in ${x} <b class='ft__on-surface'>${y}</b>",
@ -768,7 +770,7 @@
"openSyncTip2": "Beim Wechsel von deaktiviert auf aktiviert wird empfohlen, manuell auf die Synchronisationstaste zu klicken, um eine Synchronisation auszulösen.",
"syncMode": "Cloud-Synchronisationsmodus",
"syncModeTip": "Der Synchronisationsmodus kann nach der Aktivierung der Cloud-Synchronisation weiter ausgewählt werden.",
"syncMode1": "Automatisch (Synchronisation alle 30 Sekunden, nachdem sich die Daten nicht mehr ändern)",
"syncMode1": "Automatisch",
"syncMode2": "Manuell (automatische Synchronisation nur einmal beim Starten und Schließen der Software, andere Zeitpunkte müssen manuell ausgelöst werden)",
"syncMode3": "Vollständige manuelle Synchronisation (keine Synchronisation beim Start und beim Schließen, vollständige manuelle Kontrolle über den Synchronisationszeitpunkt und die Synchronisationsrichtung)",
"cloudSync": "Cloud-Synchronisation",

View file

@ -768,7 +768,7 @@
"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)",
"syncMode1": "Auto",
"syncMode2": "Manual (automatic auto only once when the software is started and closed, other times need to manually trigger)",
"syncMode3": "Full manual sync (no sync on startup and shutdown, full manual control of sync timing and sync direction)",
"cloudSync": "Cloud sync",

View file

@ -1,4 +1,8 @@
{
"second": "second",
"syncInterval": "Sync interval",
"second": "segundo",
"syncInterval": "intervalo de sincronización",
"removeAV": "Eliminar de la base de datos",
"empty": "Vacío",
"newRowInRelation": "Crear una nueva entrada en ${x} <b class='ft__on-surface'>${y}</b>",
@ -768,7 +772,7 @@
"openSyncTip2": "Al cambiar de desactivado a activado, se recomienda hacer clic manualmente en el botón de sincronización para activar una sincronización",
"syncMode": "Modo de sincronización en la nube",
"syncModeTip": "El modo de sincronización se puede seguir seleccionando después de habilitar la sincronización en la nube",
"syncMode1": "Auto (sincronización cada 30 segundos después de que los datos dejen de cambiar)",
"syncMode1": "Auto",
"syncMode2": "Manual (automático sólo una vez cuando se inicia y se cierra el software, otras veces hay que activarlo manualmente)",
"syncMode3": "Manual Completa (sin sincronización al iniciar y apagar, control manual completo de sincronización y dirección de sincronización)",
"cloudSync": "Sincronización en la nube",

View file

@ -1,4 +1,6 @@
{
"second": "seconde",
"syncInterval": "intervalle de synchronisation",
"removeAV": "Supprimer de la base de données",
"empty": "Vide",
"newRowInRelation": "Créer une nouvelle entrée dans ${x} <b class='ft__on-surface'>${y}</b>",
@ -768,7 +770,7 @@
"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)",
"syncMode1": "Automatique",
"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)",
"syncMode3": "Manuelle Complète (pas de synchronisation au démarrage et à l'arrêt, contrôle manuel complet de la synchronisation et du sens de synchronisation)",
"cloudSync": "Cloud Sync",

View file

@ -1,4 +1,6 @@
{
"second": "שנייה",
"syncInterval": "מרווח סנכרון",
"removeAV": "הסר ממסד הנתונים",
"empty": "ריק",
"newRowInRelation": "צור ערך חדש ב-${x} <b class='ft__on-surface'>${y}</b>",
@ -768,7 +770,7 @@
"openSyncTip2": "כאשר אתה משנה מ-מושבת ל-פעיל, מומלץ ללחוץ ידנית על כפתור הסנכרון כדי להפעיל סנכרון",
"syncMode": "מצב סנכרון בענן",
"syncModeTip": "מצב הסנכרון ניתן לבחירה נוספת לאחר שהסנכרון בענן הופעל",
"syncMode1": "אוטומטי (סנכרון כל 30 שניות לאחר שהנתונים לא משתנים יותר)",
"syncMode1": "אוטומטי",
"syncMode2": "ידני (אוטומטית בהחלט פעם אחת בעת הפעלת התוכנה והכיבוי, פעמים אחרות יש להפעיל ידנית)",
"syncMode3": "סנכרון ידני מלא (אין סנכרון בעת הפעלה וכיבוי, את שליטת הזמן והכיוונים של הסנכרון באופן ידני)",
"cloudSync": "סנכרון בענן",

View file

@ -1,4 +1,6 @@
{
"second": "secondo",
"syncInterval": "intervallo di sincronizzazione",
"removeAV": "Rimuovi dal database",
"empty": "Vuoto",
"newRowInRelation": "Crea una nuova voce in ${x} <b class='ft__on-surface'>${y}</b>",
@ -768,7 +770,7 @@
"openSyncTip2": "Quando si cambia da disabilitato ad abilitato, si consiglia di fare clic manualmente sul pulsante di sincronizzazione per avviare la sincronizzazione",
"syncMode": "Modalità di sincronizzazione cloud",
"syncModeTip": "La modalità di sincronizzazione può essere ulteriormente selezionata dopo l'abilitazione della sincronizzazione cloud",
"syncMode1": "Auto (sincronizza ogni 30 secondi dopo che i dati non cambiano più)",
"syncMode1": "Auto",
"syncMode2": "Manuale (auto automatico solo una volta quando il software viene avviato e chiuso, altre volte richiede l'attivazione manuale)",
"syncMode3": "Sincronizzazione completamente manuale (nessuna sincronizzazione all'avvio e alla chiusura, controllo manuale completo del momento e della direzione della sincronizzazione)",
"cloudSync": "Sincronizzazione cloud",

View file

@ -1,4 +1,6 @@
{
"second": "秒",
"syncInterval": "同期間隔",
"removeAV": "データベースから削除",
"empty": "空白",
"newRowInRelation": "${x} に新しい項目を作成 <b class='ft__on-surface'>${y}</b>",
@ -768,7 +770,7 @@
"openSyncTip2": "無効から有効に変更した場合は手動で同期ボタンをクリックして同期をトリガーすることをお勧めします",
"syncMode": "クラウド同期モード",
"syncModeTip": "クラウド同期を有効にすると同期モードを選択できます",
"syncMode1": "自動 (起動時と終了時に同期され、アプリケーションの使用中は同期アルゴリズムにしたがって自動的に同期されます)",
"syncMode1": "自動",
"syncMode2": "手動 (起動時と終了時に一度だけ同期され、それ以外の場合は手動で同期をトリガーする必要があります)",
"syncMode3": "完全手動同期 (起動と終了時に同期されず、同期タイミングと同期方向をすべて手動で制御します)",
"cloudSync": "クラウド同期",

View file

@ -1,4 +1,6 @@
{
"second": "sekunda",
"syncInterval": "interwał synchronizacji",
"removeAV": "Usuń z bazy danych",
"empty": "Pusty",
"newRowInRelation": "Utwórz nowy wpis w ${x} <b class='ft__on-surface'>${y}</b>",
@ -768,7 +770,7 @@
"openSyncTip2": "Podczas zmiany z wyłączonej na włączoną, zaleca się ręczne kliknięcie przycisku synchronizacji, aby wyzwolić synchronizację",
"syncMode": "Tryb synchronizacji w chmurze",
"syncModeTip": "Tryb synchronizacji można dalej wybrać po włączeniu synchronizacji w chmurze",
"syncMode1": "Auto (synchronizacja co 30 sekund po tym, jak dane przestają się zmieniać)",
"syncMode1": "Auto",
"syncMode2": "Ręczny (automatyczna synchronizacja tylko raz przy uruchamianiu i zamykaniu oprogramowania, inne czasy wymagają ręcznego wyzwolenia)",
"syncMode3": "W pełni ręczna synchronizacja (brak synchronizacji przy uruchamianiu i zamykaniu, pełna ręczna kontrola nad czasem synchronizacji i kierunkiem synchronizacji)",
"cloudSync": "Synchronizacja w chmurze",

View file

@ -1,4 +1,6 @@
{
"second": "секунда",
"syncInterval": "интервал синхронизации",
"removeAV": "Удалить из базы данных",
"empty": "Пусто",
"newRowInRelation": "Создать новую запись в ${x} <b class='ft__on-surface'>${y}</b>",
@ -768,7 +770,7 @@
"openSyncTip2": "При изменении с отключенного на включенное рекомендуется вручную нажать кнопку синхронизации для запуска синхронизации",
"syncMode": "Режим облачной синхронизации",
"syncModeTip": "Режим синхронизации можно дополнительно выбрать после включения облачной синхронизации",
"syncMode1": "Авто (синхронизация каждые 30 секунд, когда данные больше не изменяются)",
"syncMode1": "Авто",
"syncMode2": "Ручной (автоматическая синхронизация только один раз при запуске и закрытии программы, в другие разы необходимо вручную запустить)",
"syncMode3": "Полная ручная синхронизация (не синхронизируется при запуске и завершении, полный ручной контроль времени и направления синхронизации)",
"cloudSync": "Облачная синхронизация",

View file

@ -1,4 +1,6 @@
{
"second": "秒",
"syncInterval": "同步間隔",
"removeAV": "從資料庫中移除",
"empty": "空白",
"newRowInRelation": "在 ${x} 中新建條目 <b class='ft__on-surface'>${y}</b>",
@ -768,7 +770,7 @@
"openSyncTip2": "從禁用改為啟用時建議手動點擊同步按鈕觸發一次同步",
"syncMode": "雲端同步模式",
"syncModeTip": "啟用雲端同步後可進一步選擇同步模式",
"syncMode1": "自動同步(資料不再變動後 30 秒進行一次同步)",
"syncMode1": "自動同步",
"syncMode2": "手動同步(僅啟動和關閉軟體時自動同步一次,其他時候需要手動觸發同步)",
"syncMode3": "完全手動同步(啟動和關閉時均不同步,完全手動控制同步時機和同步方向)",
"cloudSync": "雲端同步",

View file

@ -1,4 +1,7 @@
{
"second": "秒",
"syncInterval": "同步间隔",
"syncIntervalTip": "数据不再变动后自动进行数据同步",
"removeAV": "从数据库中移除",
"empty": "空白",
"newRowInRelation": "在 ${x} 中新建条目 <b class='ft__on-surface'>${y}</b>",
@ -768,7 +771,7 @@
"openSyncTip2": "从禁用改为启用时建议手动点击同步按钮触发一次同步",
"syncMode": "云端同步模式",
"syncModeTip": "启用云端同步后可进一步选择同步模式",
"syncMode1": "自动同步(数据不再变动后 30 秒进行一次同步)",
"syncMode1": "自动同步",
"syncMode2": "手动同步(仅启动和关闭软件时自动同步一次,其他时候需要手动触发同步)",
"syncMode3": "完全手动同步(启动和关闭时均不同步,完全手动控制同步时机和同步方向)",
"cloudSync": "云端同步",

View file

@ -392,6 +392,14 @@ export const repos = {
<option value="3" ${window.siyuan.config.sync.mode === 3 ? "selected" : ""}>${window.siyuan.languages.syncMode3}</option>
</select>
</div>
<label class="fn__flex b3-label${(window.siyuan.config.sync.mode !== 1 || window.siyuan.config.system.container === "docker" || window.siyuan.config.sync.provider !== 0) ? " fn__none" : ""}">
<div class="fn__flex-1">
${window.siyuan.languages.syncInterval}
<div class="b3-label__text">${window.siyuan.languages.syncIntervalTip}</div>
</div>
<span class="fn__space"></span>
<input type="number" min="30" max="43200" id="syncInterval" class="b3-text-field fn__flex-center" value="${window.siyuan.config.sync.interval}" > ${window.siyuan.languages.second}
</label>
<label class="fn__flex b3-label${(window.siyuan.config.sync.mode !== 1 || window.siyuan.config.system.container === "docker" || window.siyuan.config.sync.provider !== 0) ? " fn__none" : ""}">
<div class="fn__flex-1">
${window.siyuan.languages.syncPerception}
@ -434,6 +442,21 @@ export const repos = {
processSync();
});
});
const syncIntervalElement = repos.element.querySelector("#syncInterval") as HTMLInputElement;
syncIntervalElement.addEventListener("change", () => {
let interval = parseInt(syncIntervalElement.value);
if (30 > interval) {
interval = 30;
}
if (43200 < interval) {
interval = 43200;
}
fetchPost("/api/sync/setSyncInterval", {interval: interval}, () => {
window.siyuan.config.sync.interval = interval;
processSync();
});
});
const syncPerceptionElement = repos.element.querySelector("#syncPerception") as HTMLInputElement;
syncPerceptionElement.addEventListener("change", () => {
fetchPost("/api/sync/setSyncPerception", {enabled: syncPerceptionElement.checked}, () => {
@ -452,8 +475,10 @@ export const repos = {
fetchPost("/api/sync/setSyncMode", {mode: parseInt(syncModeElement.value, 10)}, () => {
if (syncModeElement.value === "1" && window.siyuan.config.sync.provider === 0 && window.siyuan.config.system.container !== "docker") {
syncPerceptionElement.parentElement.classList.remove("fn__none");
syncIntervalElement.parentElement.classList.remove("fn__none");
} else {
syncPerceptionElement.parentElement.classList.add("fn__none");
syncIntervalElement.parentElement.classList.add("fn__none");
}
window.siyuan.config.sync.mode = parseInt(syncModeElement.value, 10);
});
@ -475,8 +500,10 @@ export const repos = {
syncConfigElement.classList.add("fn__none");
if (window.siyuan.config.sync.mode !== 1 || window.siyuan.config.system.container === "docker" || window.siyuan.config.sync.provider !== 0) {
syncPerceptionElement.parentElement.classList.add("fn__none");
syncIntervalElement.parentElement.classList.add("fn__none");
} else {
syncPerceptionElement.parentElement.classList.remove("fn__none");
syncIntervalElement.parentElement.classList.remove("fn__none");
}
});
});

View file

@ -1349,6 +1349,10 @@ declare namespace Config {
* - `3`: Completely manual synchronization
*/
mode: number;
/**
* Synchronization interval (unit: seconds)
*/
interval: number;
/**
* Whether to enable synchronization perception
*/

View file

@ -237,6 +237,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/cloud/getCloudSpace", model.CheckAuth, model.CheckAdminRole, getCloudSpace)
ginServer.Handle("POST", "/api/sync/setSyncEnable", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setSyncEnable)
ginServer.Handle("POST", "/api/sync/setSyncInterval", model.CheckAuth, setSyncInterval)
ginServer.Handle("POST", "/api/sync/setSyncPerception", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setSyncPerception)
ginServer.Handle("POST", "/api/sync/setSyncGenerateConflictDoc", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setSyncGenerateConflictDoc)
ginServer.Handle("POST", "/api/sync/setSyncMode", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setSyncMode)

View file

@ -541,6 +541,17 @@ func setSyncEnable(c *gin.Context) {
model.SetSyncEnable(enabled)
}
func setSyncInterval(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
interval := int(arg["interval"].(float64))
model.SetSyncInterval(interval)
}
func setSyncPerception(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)

View file

@ -21,6 +21,7 @@ type Sync struct {
Enabled bool `json:"enabled"` // 是否开启同步
Perception bool `json:"perception"` // 是否开启感知
Mode int `json:"mode"` // 同步模式0未设置为兼容已有配置initConf 函数中会转换为 11自动2手动 https://github.com/siyuan-note/siyuan/issues/50893完全手动 https://github.com/siyuan-note/siyuan/issues/7295
Interval int `json:"interval"` // 自动同步间隔,单位:秒
Synced int64 `json:"synced"` // 最近同步时间
Stat string `json:"stat"` // 最近同步统计信息
GenerateConflictDoc bool `json:"generateConflictDoc"` // 云端同步冲突时是否生成冲突文档
@ -37,6 +38,7 @@ func NewSync() *Sync {
Mode: 1,
GenerateConflictDoc: false,
Provider: ProviderSiYuan,
Interval: 30,
}
}

View file

@ -344,6 +344,12 @@ func InitConf() {
if 0 == Conf.Sync.Mode {
Conf.Sync.Mode = 1
}
if 30 > Conf.Sync.Interval {
Conf.Sync.Interval = 30
}
if 60*60*12 < Conf.Sync.Interval {
Conf.Sync.Interval = 60 * 60 * 12
}
if nil == Conf.Sync.S3 {
Conf.Sync.S3 = &conf.S3{PathStyle: true, SkipTlsVerify: true}
}

View file

@ -389,6 +389,20 @@ func SetSyncEnable(b bool) {
return
}
func SetSyncInterval(interval int) {
if 30 > interval {
interval = 30
}
if 43200 < interval {
interval = 43200
}
Conf.Sync.Interval = interval
Conf.Save()
planSyncAfter(time.Duration(interval) * time.Second)
return
}
func SetSyncPerception(b bool) {
if util.ContainerDocker == util.Container {
b = false
@ -641,7 +655,7 @@ func getSyncIgnoreLines() (ret []string) {
func IncSync() {
syncSameCount.Store(0)
planSyncAfter(30 * time.Second)
planSyncAfter(time.Duration(Conf.Sync.Interval) * time.Second)
}
func planSyncAfter(d time.Duration) {