feat: auto-backup UI and window close hook

This commit is contained in:
Your Name
2026-02-20 15:41:38 +02:00
parent 0ae431b8ac
commit b7b1789380
2 changed files with 93 additions and 0 deletions

View File

@@ -188,6 +188,23 @@ onMounted(async () => {
registerShortcuts()
// Auto-backup on window close
try {
const { getCurrentWindow } = await import('@tauri-apps/api/window')
const win = getCurrentWindow()
win.onCloseRequested(async () => {
if (settingsStore.settings.auto_backup === 'true' && settingsStore.settings.backup_path) {
try {
await invoke('auto_backup', { backupDir: settingsStore.settings.backup_path })
} catch (e) {
console.error('Auto-backup failed:', e)
}
}
})
} catch (e) {
console.error('Failed to register close handler:', e)
}
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
if (settingsStore.settings.theme_mode === 'system') applyTheme()
})