fix: show sync warnings in settings

This commit is contained in:
mirivlad 2026-06-04 03:53:17 +08:00
parent 7641a311cc
commit c40d8c9dd3
8 changed files with 38 additions and 8 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -16,8 +16,8 @@
background: #13131f;
}
</style>
<script type="module" crossorigin src="/assets/main-DnJYoBUl.js"></script>
<link rel="stylesheet" crossorigin href="/assets/main-DUL0iWPC.css">
<script type="module" crossorigin src="/assets/main-gfkCdjpq.js"></script>
<link rel="stylesheet" crossorigin href="/assets/main-ANUqg_zC.css">
</head>
<body>
<div id="app"></div>

View File

@ -7,6 +7,7 @@
let loading = false
let errorMsg = ''
let resultMsg = ''
let resultKind = ''
let serverUrl = ''
let username = ''
@ -41,6 +42,7 @@
async function testConnection() {
loading = true
errorMsg = ''
resultKind = ''
connectionOk = null
try {
await wailsCall('SyncTestConnection', serverUrl, username, password)
@ -56,6 +58,7 @@
async function configureSync() {
loading = true
errorMsg = ''
resultKind = ''
try {
await wailsCall('SyncConfigure', serverUrl, username, password)
resultMsg = 'configured'
@ -69,12 +72,29 @@
loading = false
}
function syncResultWarning(result) {
const conflicts = Array.isArray(result?.conflicts) ? result.conflicts : []
const applyErrors = Array.isArray(result?.applyErrors) ? result.applyErrors : []
const parts = []
if (conflicts.length > 0) {
parts.push(t('sync.conflictsCount', { count: conflicts.length }))
}
if (applyErrors.length > 0) {
parts.push(t('sync.applyErrorsCount', { count: applyErrors.length }))
}
return parts.join(' · ')
}
async function runSyncNow() {
loading = true
errorMsg = ''
resultKind = ''
try {
const r = await wailsCall('SyncNow')
resultMsg = 'pushed ' + r.pushed + ', pulled ' + r.pulled
const summary = t('sync.pushedPulled', { pushed: r?.pushed || 0, pulled: r?.pulled || 0 })
const warning = syncResultWarning(r)
resultMsg = warning ? summary + ' · ' + warning : summary
resultKind = warning ? 'warning' : ''
await load()
if (onRefresh) onRefresh()
} catch (e) {
@ -87,6 +107,7 @@
try {
await wailsCall('SyncSetInterval', syncInterval)
resultMsg = t('sync.settingsSaved')
resultKind = ''
} catch (e) { errorMsg = String(e) }
}
@ -97,6 +118,7 @@
async function doDisconnect() {
showDisconnectConfirm = false
loading = true
resultKind = ''
try {
await wailsCall('SyncDisconnect')
resultMsg = 'disconnected'
@ -113,6 +135,7 @@
async function doResetKey() {
showResetKeyConfirm = false
loading = true
resultKind = ''
try {
await wailsCall('ResetSyncKey')
resultMsg = 'key reset'
@ -143,7 +166,7 @@
<div class="error-msg">{errorMsg}</div>
{/if}
{#if resultMsg && !errorMsg}
<div class="result-msg">{resultMsg}</div>
<div class="result-msg" class:warning={resultKind === 'warning'}>{resultMsg}</div>
{/if}
{#if settings && settings.enabled}
@ -375,6 +398,11 @@
color: #34d399;
font-size: 0.85rem;
}
.result-msg.warning {
background: rgba(245, 158, 11, 0.1);
border-color: rgba(245, 158, 11, 0.3);
color: #f59e0b;
}
.modal-overlay {
position: fixed;
inset: 0;

View File

@ -408,6 +408,7 @@ export default {
'sync.running': 'Syncing...',
'sync.conflictsCount': 'Conflicts: {count}',
'sync.applyErrorsCount': 'Apply errors: {count}',
'sync.pushedPulled': 'Pushed: {pushed}, pulled: {pulled}',
'error.generic': 'An error occurred',
'error.invalidCredentials': 'Invalid username or password',
'error.accountBlocked': 'Account blocked',

View File

@ -432,6 +432,7 @@ export default {
'sync.running': 'Синхронизация...',
'sync.conflictsCount': 'Конфликты: {count}',
'sync.applyErrorsCount': 'Ошибки применения: {count}',
'sync.pushedPulled': 'Отправлено: {pushed}, получено: {pulled}',
'error.generic': 'Произошла ошибка',
'error.invalidCredentials': 'Неверный логин или пароль',