mirror of
https://gitlab.com/ArkHost/HelixNotes.git
synced 2026-07-24 07:45:57 +02:00
Scheduled backups, fixed settings/info panel sizing, added source mode shortcut, removed unused title mode setting
This commit is contained in:
@@ -34,18 +34,46 @@
|
||||
const appWindow = getCurrentWindow();
|
||||
const isMac = navigator.platform.startsWith('Mac');
|
||||
const isMobile = /android|ios/i.test(navigator.userAgent);
|
||||
import { loadVaultState, saveVaultState, readNote, createDailyNote } from '$lib/api';
|
||||
import { loadVaultState, saveVaultState, readNote, createDailyNote, createBackup } from '$lib/api';
|
||||
import { debounce } from '$lib/utils/debounce';
|
||||
import { get } from 'svelte/store';
|
||||
import type { VaultState, FileEvent } from '$lib/types';
|
||||
|
||||
let sidebar: Sidebar;
|
||||
let noteList: NoteList;
|
||||
let editor: Editor;
|
||||
let unlistenFileChange: (() => void) | null = null;
|
||||
let backupInterval: ReturnType<typeof setInterval> | null = null;
|
||||
let navigatingFromHistory = false;
|
||||
let noteHistory: string[] = [];
|
||||
let noteHistoryIndex = -1;
|
||||
|
||||
function parseFrequencyMs(freq: string): number {
|
||||
switch (freq) {
|
||||
case '6h': return 6 * 60 * 60 * 1000;
|
||||
case '12h': return 12 * 60 * 60 * 1000;
|
||||
case '7d': return 7 * 24 * 60 * 60 * 1000;
|
||||
case '24h': default: return 24 * 60 * 60 * 1000;
|
||||
}
|
||||
}
|
||||
|
||||
async function checkScheduledBackup() {
|
||||
const config = get(appConfig);
|
||||
if (!config?.backup_enabled) return;
|
||||
const interval = parseFrequencyMs(config.backup_frequency);
|
||||
const last = config.last_backup_time ? new Date(config.last_backup_time).getTime() : 0;
|
||||
if (Date.now() - last >= interval) {
|
||||
const unlisten = await listen('backup-done', (event: any) => {
|
||||
if (event.payload?.success) {
|
||||
const cur = get(appConfig);
|
||||
if (cur) appConfig.set({ ...cur, last_backup_time: new Date().toISOString() });
|
||||
}
|
||||
unlisten();
|
||||
});
|
||||
try { await createBackup(); } catch (_) { unlisten(); }
|
||||
}
|
||||
}
|
||||
|
||||
// Track note navigation in history stack
|
||||
$effect(() => {
|
||||
const path = $activeNotePath;
|
||||
@@ -239,10 +267,15 @@
|
||||
await sidebar?.refresh();
|
||||
await noteList?.refresh(true);
|
||||
});
|
||||
|
||||
// Scheduled backup: check on startup and every 5 minutes
|
||||
checkScheduledBackup();
|
||||
backupInterval = setInterval(checkScheduledBackup, 5 * 60 * 1000);
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
unlistenFileChange?.();
|
||||
if (backupInterval) clearInterval(backupInterval);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -126,6 +126,7 @@
|
||||
<div class="shortcut-row"><span class="shortcut-desc">Redo</span><span class="shortcut-keys"><kbd>{modKey}</kbd>+<kbd>Shift</kbd>+<kbd>Z</kbd></span></div>
|
||||
<div class="shortcut-row"><span class="shortcut-desc">Go back</span><span class="shortcut-keys"><kbd>Alt</kbd>+<kbd>←</kbd></span></div>
|
||||
<div class="shortcut-row"><span class="shortcut-desc">Go forward</span><span class="shortcut-keys"><kbd>Alt</kbd>+<kbd>→</kbd></span></div>
|
||||
<div class="shortcut-row"><span class="shortcut-desc">Toggle source mode</span><span class="shortcut-keys"><kbd>{modKey}</kbd>+<kbd>Shift</kbd>+<kbd>M</kbd></span></div>
|
||||
<div class="shortcut-row"><span class="shortcut-desc">Exit focus mode</span><span class="shortcut-keys"><kbd>Esc</kbd></span></div>
|
||||
|
||||
<h4 class="shortcuts-group-title">Editor Commands</h4>
|
||||
@@ -164,7 +165,8 @@
|
||||
border-radius: 16px;
|
||||
box-shadow: var(--shadow-lg);
|
||||
width: 500px;
|
||||
max-height: 80vh;
|
||||
height: 80vh;
|
||||
max-height: 600px;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -201,7 +203,7 @@
|
||||
}
|
||||
|
||||
.info-body {
|
||||
padding: 0 24px 32px;
|
||||
padding: 0 24px 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
@@ -244,6 +246,7 @@
|
||||
}
|
||||
|
||||
.info-logo {
|
||||
margin-top: 12px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
|
||||
@@ -612,13 +612,7 @@
|
||||
<div class="tab-content">
|
||||
<div class="settings-section">
|
||||
<h3>Title</h3>
|
||||
<div class="setting-options">
|
||||
<button class="option-btn" class:active={titleMode === 'input'} onclick={() => { titleMode = 'input'; saveGeneralSettings(); }}>Input</button>
|
||||
<button class="option-btn" class:active={titleMode === 'heading'} onclick={() => { titleMode = 'heading'; saveGeneralSettings(); }}>Heading</button>
|
||||
<button class="option-btn" class:active={titleMode === 'hidden'} onclick={() => { titleMode = 'hidden'; saveGeneralSettings(); }}>Hidden</button>
|
||||
</div>
|
||||
<span class="setting-hint">How the note title is displayed in the editor</span>
|
||||
<label class="setting-toggle" style="margin-top: 12px;">
|
||||
<label class="setting-toggle">
|
||||
<span class="setting-label">
|
||||
<span class="setting-name">Hide title in note body</span>
|
||||
<span class="setting-desc">Hide the first heading when it matches the note title</span>
|
||||
@@ -1147,7 +1141,8 @@
|
||||
border-radius: 16px;
|
||||
box-shadow: var(--shadow-lg);
|
||||
width: 620px;
|
||||
max-height: 80vh;
|
||||
height: 80vh;
|
||||
max-height: 700px;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
Reference in New Issue
Block a user