web-app/electron/main.cjs
padreug a74148a0da chore: Set up Electron configuration and update dependencies
- Add Electron Forge configuration in forge.config.js for packaging and building the app
- Create main Electron entry point in main.cjs for application initialization
- Update package.json scripts for Electron development and building
- Add necessary Electron dependencies to package.json
- Modify .gitignore to exclude build artifacts and temporary files
- Refactor Footer and Navbar components to remove unused imports
- Enhance NostrFeed component by removing unnecessary connection logic
- Update i18n setup for better type safety and locale management
- Refactor Home component to clean up unused code
- Extend Nostr store to manage account state with TypeScript interfaces
2025-03-20 17:26:15 +01:00

48 lines
1.3 KiB
JavaScript

const { app, BrowserWindow, protocol } = require('electron');
const path = require('path');
const url = require('url');
// Handle creating/removing shortcuts on Windows when installing/uninstalling
if (require('electron-squirrel-startup')) {
app.quit();
}
const createWindow = () => {
// Create the browser window
const mainWindow = new BrowserWindow({
width: 1200,
height: 800,
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
preload: path.join(__dirname, 'preload.cjs') // Optional: for exposing APIs to renderer
}
});
// In production, load the bundled app
if (app.isPackaged) {
mainWindow.loadFile(path.join(__dirname, '../dist/index.html'));
} else {
// In dev mode, load from the vite dev server
mainWindow.loadURL('http://localhost:5173');
mainWindow.webContents.openDevTools();
}
};
// Create window when Electron is ready
app.whenReady().then(() => {
createWindow();
app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
// Quit when all windows are closed, except on macOS
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});