Skip to content

Instantly share code, notes, and snippets.

@Rn145
Last active March 23, 2024 05:49
Show Gist options
  • Save Rn145/25493b427379ff70f089d731a9397c6a to your computer and use it in GitHub Desktop.
Save Rn145/25493b427379ff70f089d731a9397c6a to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'">
<title>Exception from webContents.send()</title>
</head>
<body>
<h1>Exception from webContents.send()</h1>
</body>
</html>
const { app, BrowserWindow } = require('electron')
const path = require('node:path')
function createWindow () {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
mainWindow.loadFile('index.html');
//----------------------------------------------------------------------
mainWindow.on('ready-to-show', ()=>{
try{
mainWindow.webContents.send('CHANNEL_1', Symbol());
}
catch(error){
console.log('sucessful catched', error);
}
})
//----------------------------------------------------------------------
}
app.whenReady().then(() => {
createWindow()
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})
const Electron = require('electron');
Electron.ipcRenderer.on('CHANNEL_1', (event, data)=>{
console.log(data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment