diff --git a/renderer/index.html b/renderer/index.html index a632886..fe12e5f 100644 --- a/renderer/index.html +++ b/renderer/index.html @@ -8,7 +8,6 @@
-
@@ -31,14 +30,11 @@ Bereit
-
- -
+
- - -
- - + + + \ No newline at end of file diff --git a/renderer/renderer.js b/renderer/renderer.js index 733cc26..08da43a 100644 --- a/renderer/renderer.js +++ b/renderer/renderer.js @@ -314,7 +314,52 @@ async function updateEditor() { imgSrc = 'file:///' + currentActiveTab.replace(/\\/g, '/'); } - imagePreview.innerHTML = `${tab.name}Bild konnte nicht geladen werden';">`; + // Erstelle Bild-Element mit verbesserter Darstellung + const img = document.createElement('img'); + img.src = imgSrc; + img.alt = tab.name; + img.style.cssText = ` + max-width: 100%; + max-height: 85vh; + width: auto; + height: auto; + display: block; + margin: 0 auto; + object-fit: contain; + cursor: zoom-in; + `; + + // Click zum Zoomen (Original-Größe) + let isZoomed = false; + img.onclick = function() { + if (isZoomed) { + img.style.maxWidth = '100%'; + img.style.maxHeight = '85vh'; + img.style.cursor = 'zoom-in'; + isZoomed = false; + } else { + img.style.maxWidth = 'none'; + img.style.maxHeight = 'none'; + img.style.cursor = 'zoom-out'; + isZoomed = true; + } + }; + + img.onerror = function() { + imagePreview.innerHTML = '
Bild konnte nicht geladen werden
'; + }; + + // Container für zentrierte Anzeige + imagePreview.innerHTML = ''; + imagePreview.style.cssText = ` + display: flex; + justify-content: center; + align-items: center; + min-height: 400px; + overflow: auto; + padding: 20px; + `; + imagePreview.appendChild(img); } } else { // Zeige Text Editor @@ -1728,6 +1773,7 @@ window.addEventListener('DOMContentLoaded', async () => { setupGlobalDropZone(); setStatus('Ready'); + initUpdater(); // Updater initialisieren updateNavigationUI(); }); /* ================================ @@ -2957,4 +3003,82 @@ document.addEventListener('keydown', (e) => { } } }); +/* ======================================== + UPDATER FUNKTIONEN (Optimiert & Synchronisiert) + ======================================== */ +async function initUpdater() { + try { + const versionRes = await window.electronAPI.getAppVersion(); + if (versionRes && versionRes.ok && $('appVersion')) { + $('appVersion').value = versionRes.version; + } + } catch (error) { + console.error('[Renderer] Fehler beim Laden der Version:', error); + } + + // Manueller Check Button in Settings + if ($('btnCheckUpdates')) { + $('btnCheckUpdates').onclick = async () => { + const btn = $('btnCheckUpdates'); + const originalHTML = btn.innerHTML; + btn.innerHTML = '⏳ Suche...'; + btn.disabled = true; + + try { + await window.electronAPI.checkForUpdates(); + setStatus('Update-Suche abgeschlossen'); + } catch (error) { + setStatus('Fehler bei der Update-Prüfung'); + } finally { + setTimeout(() => { + btn.innerHTML = originalHTML; + btn.disabled = false; + }, 1500); + } + }; + } +} + +// Event-Listener für das Update-Modal +if (window.electronAPI.onUpdateAvailable) { + window.electronAPI.onUpdateAvailable((info) => { + const modal = $('updateModal'); + const versionInfo = $('updateVersionInfo'); + const changelog = $('updateChangelog'); + + if (versionInfo) versionInfo.innerText = `Version ${info.version} verfügbar!`; + if (changelog) changelog.innerText = info.body || 'Keine Release-Notes vorhanden.'; + if (modal) modal.classList.remove('hidden'); + + // Button: Jetzt installieren + const updateBtn = $('btnStartUpdate'); + if (updateBtn) { + updateBtn.onclick = () => { + if (modal) modal.classList.add('hidden'); + setStatus('Download gestartet...'); + // Aufruf der korrekten Preload-Funktion + window.electronAPI.startUpdateDownload(info.asset); + }; + } + + // Button: Später + const ignoreBtn = $('btnIgnoreUpdate'); + if (ignoreBtn) { + ignoreBtn.onclick = () => { if (modal) modal.classList.add('hidden'); }; + } + }); +} + +// AM ENDE DER DATEI: Initialisierung beim Start +document.addEventListener('DOMContentLoaded', () => { + // 1. Basis-Setup (Settings-Feld füllen etc.) + initUpdater(); + + // 2. AUTOMATISCHER UPDATE-CHECK BEIM START + // Wir warten 3 Sekunden, damit die App in Ruhe laden kann + setTimeout(() => { + console.log("[Auto-Updater] Suche im Hintergrund nach Updates..."); + window.electronAPI.checkForUpdates(); + }, 3000); +}); \ No newline at end of file diff --git a/renderer/style.css b/renderer/style.css index db0eb27..74bf42b 100644 --- a/renderer/style.css +++ b/renderer/style.css @@ -1383,4 +1383,31 @@ progress::-moz-progress-bar { 50% { opacity: 1; } +} + +.update-card { + max-width: 400px !important; + border: 1px solid var(--accent-primary); + box-shadow: 0 0 20px rgba(0, 212, 255, 0.2); +} + +.update-header { + display: flex; + align-items: center; + gap: 15px; + margin-bottom: 15px; +} + +.update-icon { font-size: 2rem; } + +.changelog-box { + background: var(--bg-primary); + padding: 10px; + border-radius: 8px; + margin: 15px 0; + max-height: 150px; + overflow-y: auto; + font-size: 0.9rem; + color: var(--text-secondary); + border: 1px solid rgba(255,255,255,0.05); } \ No newline at end of file