From ef2c8c76c43ba349feaf185a5703f45a1417685b Mon Sep 17 00:00:00 2001 From: mirivlad Date: Sat, 20 Jun 2026 03:02:34 +0800 Subject: [PATCH] fix: use api.backend.call() instead of broken wailsCall, fix styling - Replace direct window['go']['main']['App'] access with api.backend.call() - Use hardcoded colors matching PluginManager modal theme (#16213e, #0f3460, etc.) - Labels above inputs, full-width inputs, proper form layout - Add explicit btn/modal styles instead of relying on CSS variables --- plugins/sync/frontend/src/SyncSettings.svelte | 144 ++++++++++++------ 1 file changed, 95 insertions(+), 49 deletions(-) diff --git a/plugins/sync/frontend/src/SyncSettings.svelte b/plugins/sync/frontend/src/SyncSettings.svelte index 09e6165..13c671f 100644 --- a/plugins/sync/frontend/src/SyncSettings.svelte +++ b/plugins/sync/frontend/src/SyncSettings.svelte @@ -16,19 +16,16 @@ let showResetKeyConfirm = false let connectionOk = null - function wailsCall(method, ...args) { - try { - if (window['go'] && window['go']['main'] && window['go']['main']['App']) { - const fn = window['go']['main']['App'][method] - if (typeof fn === 'function') return fn(...args) - } - } catch (e) { console.error('Wails error:', method, e) } - return Promise.reject(new Error('Wails not connected: ' + method)) + async function backendCall(method, ...args) { + if (api && api.backend && typeof api.backend.call === 'function') { + return await api.backend.call(method, ...args) + } + throw new Error('Plugin API backend.call not available') } async function load() { try { - settings = await wailsCall('SyncStatus') + settings = await backendCall('SyncStatus') if (settings) { serverUrl = settings.serverUrl || '' syncInterval = settings.syncInterval || 0 @@ -45,7 +42,7 @@ resultKind = '' connectionOk = null try { - await wailsCall('SyncTestConnection', serverUrl, username, password) + await backendCall('SyncTestConnection', serverUrl, username, password) connectionOk = true resultMsg = 'connection ok' } catch (e) { @@ -60,7 +57,7 @@ errorMsg = '' resultKind = '' try { - await wailsCall('SyncConfigure', serverUrl, username, password) + await backendCall('SyncConfigure', serverUrl, username, password) resultMsg = 'configured' username = '' password = '' @@ -89,7 +86,7 @@ errorMsg = '' resultKind = '' try { - const r = await wailsCall('SyncNow') + const r = await backendCall('SyncNow') const summary = 'pushed ' + (r?.pushed || 0) + ', pulled ' + (r?.pulled || 0) const warning = syncResultWarning(r) resultMsg = warning ? summary + ' ยท ' + warning : summary @@ -106,7 +103,7 @@ errorMsg = '' resultKind = '' try { - await wailsCall('SyncSetInterval', syncInterval) + await backendCall('SyncSetInterval', syncInterval) resultMsg = 'settings saved' resultKind = '' } catch (e) { @@ -122,7 +119,7 @@ errorMsg = '' resultKind = '' try { - await wailsCall('SyncSetInterval', minutes) + await backendCall('SyncSetInterval', minutes) resultMsg = autoSync ? 'auto-sync enabled' : 'auto-sync disabled' resultKind = '' } catch (e) { @@ -140,7 +137,7 @@ loading = true resultKind = '' try { - await wailsCall('SyncDisconnect') + await backendCall('SyncDisconnect') resultMsg = 'disconnected' await load() } catch (e) { errorMsg = String(e) } @@ -156,7 +153,7 @@ loading = true resultKind = '' try { - await wailsCall('ResetSyncKey') + await backendCall('ResetSyncKey') resultMsg = 'key reset' await load() } catch (e) { errorMsg = String(e) } @@ -242,41 +239,33 @@
- + +
+ + +
{:else}
- + +
- + +
- + +