Add advanced generation options with Explicit and Smart modes

- Implemented `AdvancedGenerationOptions` component for toggling Explicit and Smart modes with confirmation dialogs.
- Integrated generation options into `GhostWriter`, `DraftCompanion`, and `ShortStoryGenerator`.
- Introduced `ToggleWithConfirmation` component for user interaction with alerts.
- Updated `InputField` to support centered alignment for better layout flexibility.
- Localized Explicit and Smart mode strings in English and French.
- Enhanced content preview logic to filter placeholder text before display.
- Added `autoUpdater` initialization checks and refactored updater setup for improved reliability.
This commit is contained in:
natreex
2026-01-17 23:26:22 -05:00
parent 0020b3abbd
commit c62a7eb0f7
11 changed files with 335 additions and 34 deletions

75
electron/autoUpdater.ts Normal file
View File

@@ -0,0 +1,75 @@
import pkg from 'electron-updater';
import type { UpdateInfo } from 'electron-updater';
const { autoUpdater } = pkg;
import { app, BrowserWindow } from 'electron';
const updateCheckInterval = 4 * 60 * 60 * 1000; // 4 heures
let initialized = false;
let currentWindow: BrowserWindow | null = null;
export function initAutoUpdater(window: BrowserWindow): void {
currentWindow = window;
if (!app.isPackaged) {
console.log('[AutoUpdater] Skipped in development mode');
return;
}
// Si déjà initialisé, juste mettre à jour la fenêtre cible
if (initialized) {
console.log('[AutoUpdater] Window target updated');
return;
}
initialized = true;
// Config: télécharge auto, installe au quit
autoUpdater.autoDownload = true;
autoUpdater.autoInstallOnAppQuit = true;
autoUpdater.on('checking-for-update', () => {
console.log('[AutoUpdater] Checking for updates...');
});
autoUpdater.on('update-available', (info: UpdateInfo) => {
console.log('[AutoUpdater] Update available:', info.version);
currentWindow?.webContents.send('update:available', info.version);
});
autoUpdater.on('update-not-available', () => {
console.log('[AutoUpdater] App is up to date');
});
autoUpdater.on('download-progress', (progress) => {
const percent = Math.round(progress.percent);
console.log(`[AutoUpdater] Downloading: ${percent}%`);
currentWindow?.webContents.send('update:progress', percent);
});
autoUpdater.on('update-downloaded', (info: UpdateInfo) => {
console.log('[AutoUpdater] Update ready:', info.version);
currentWindow?.webContents.send('update:ready', info.version);
});
autoUpdater.on('error', (error: Error) => {
console.error('[AutoUpdater] Error:', error.message);
});
// Check initial
autoUpdater.checkForUpdates().catch((err) => {
console.error('[AutoUpdater] Check failed:', err.message);
});
// Re-check périodique
setInterval(() => {
autoUpdater.checkForUpdates().catch((err) => {
console.error('[AutoUpdater] Periodic check failed:', err.message);
});
}, updateCheckInterval);
}
// Pour forcer l'installation immédiate (optionnel, appelable depuis le renderer)
export function installUpdateNow(): void {
autoUpdater.quitAndInstall(false, true);
}

View File

@@ -87,6 +87,9 @@ function createLoginWindow(): void {
loginWindow.once('ready-to-show', () => {
loginWindow?.show();
if (loginWindow) {
initAutoUpdater(loginWindow);
}
});
loginWindow.on('closed', () => {
@@ -145,7 +148,9 @@ function createMainWindow(): void {
mainWindow.once('ready-to-show', () => {
mainWindow?.show();
initAutoUpdater(mainWindow);
if (mainWindow) {
initAutoUpdater(mainWindow);
}
});
mainWindow.on('closed', () => {