79 Zeilen
2.1 KiB
JavaScript
79 Zeilen
2.1 KiB
JavaScript
// Theme management
|
|
let isDarkMode = true;
|
|
|
|
// Initialize theme
|
|
async function initializeTheme() {
|
|
if (window.electronAPI) {
|
|
isDarkMode = await window.electronAPI.getTheme();
|
|
applyTheme(isDarkMode);
|
|
}
|
|
}
|
|
|
|
// Apply theme
|
|
function applyTheme(darkMode) {
|
|
isDarkMode = darkMode;
|
|
if (darkMode) {
|
|
document.body.classList.remove('light-mode');
|
|
document.getElementById('darkTheme').checked = true;
|
|
} else {
|
|
document.body.classList.add('light-mode');
|
|
document.getElementById('lightTheme').checked = true;
|
|
}
|
|
}
|
|
|
|
// Window controls
|
|
document.getElementById('minimizeBtn').addEventListener('click', () => {
|
|
if (window.electronAPI) window.electronAPI.minimizeWindow();
|
|
});
|
|
|
|
document.getElementById('maximizeBtn').addEventListener('click', () => {
|
|
if (window.electronAPI) window.electronAPI.maximizeWindow();
|
|
});
|
|
|
|
document.getElementById('closeBtn').addEventListener('click', () => {
|
|
if (window.electronAPI) window.electronAPI.closeWindow();
|
|
});
|
|
|
|
// Settings dialog
|
|
const settingsDialog = document.getElementById('settingsDialog');
|
|
const settingsBtn = document.getElementById('settingsBtn');
|
|
const settingsCloseBtn = document.getElementById('settingsCloseBtn');
|
|
|
|
settingsBtn.addEventListener('click', () => {
|
|
settingsDialog.classList.add('show');
|
|
});
|
|
|
|
settingsCloseBtn.addEventListener('click', () => {
|
|
settingsDialog.classList.remove('show');
|
|
});
|
|
|
|
settingsDialog.addEventListener('click', (e) => {
|
|
if (e.target === settingsDialog) {
|
|
settingsDialog.classList.remove('show');
|
|
}
|
|
});
|
|
|
|
// Theme radio buttons
|
|
document.getElementById('darkTheme').addEventListener('change', () => {
|
|
applyTheme(true);
|
|
});
|
|
|
|
document.getElementById('lightTheme').addEventListener('change', () => {
|
|
applyTheme(false);
|
|
});
|
|
|
|
// Listen for theme changes from menu
|
|
if (window.electronAPI) {
|
|
window.electronAPI.onToggleTheme((event, darkMode) => {
|
|
applyTheme(darkMode);
|
|
});
|
|
|
|
window.electronAPI.onNewFile(() => {
|
|
clearMetadata();
|
|
});
|
|
}
|
|
|
|
// Initialize on load
|
|
window.addEventListener('DOMContentLoaded', () => {
|
|
initializeTheme();
|
|
}); |