Update from Git Manager GUI

This commit is contained in:
2026-02-02 20:00:57 +01:00
parent 7d18161141
commit 94e8c21e9b
3 changed files with 204 additions and 14 deletions

View File

@@ -314,7 +314,52 @@ async function updateEditor() {
imgSrc = 'file:///' + currentActiveTab.replace(/\\/g, '/');
}
imagePreview.innerHTML = `<img src="${imgSrc}" alt="${tab.name}" onerror="this.style.display='none'; this.parentElement.innerHTML='<div style=\\"color: var(--text-muted); text-align: center;\\">Bild konnte nicht geladen werden</div>';">`;
// 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 = '<div style="color: var(--text-muted); text-align: center; padding: 40px;">Bild konnte nicht geladen werden</div>';
};
// 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);
});