Bom dia, segue meu código abaixo:
main.js
const { app, BrowserWindow, ipcMain } = require('electron');
app.on('ready', () => {
console.log('Papa Recall');
let mainWindow = new BrowserWindow({
width: 1280,
height: 800
});
console.log(__dirname);
mainWindow.loadURL(`file://${__dirname}/app/index.html`);
});
app.on('window-all-aclosed', () => {
app.quit();
});
let sobreWindow = null;
ipcMain.on('abrir-janela-sobre', () => {
if(sobreWindow == null){
sobreWindow = new BrowserWindow({
width: 300,
height: 220
});
sobreWindow.on('closed', () => {
sobreWindow = null;
});
}
sobreWindow.loadURL(`file://${__dirname}/app/sobre.html`);
});
package.json
{
"name": "paparecall-app-desktop",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "electron . /main"
},
"author": "",
"license": "ISC",
"devDependencies": {
"electron": "^6.0.8",
"electron-packager": "^14.0.6"
}
}
renderer.js
const { ipcRenderer } = require('electron');
let linkSobre = document.querySelector('#link-sobre');
linkSobre.addEventListener('click', function() {
ipcRenderer.send('abrir-janela-sobre');
});
porém a janela "sobre" não está abrindo.