docs: unify documentation example and fiddle for IPC pattern-1 (#46517)

* docs: unify documentation examples and fiddle

* docs: remove changes in ipc documentation
This commit is contained in:
Jemil Suleimanov
2025-04-10 12:08:10 +02:00
committed by GitHub
parent de407e82b7
commit 013133867b

View File

@@ -1,6 +1,12 @@
const { app, BrowserWindow, ipcMain } = require('electron/main')
const path = require('node:path')
function handleSetTitle (event, title) {
const webContents = event.sender
const win = BrowserWindow.fromWebContents(webContents)
win.setTitle(title)
}
function createWindow () {
const mainWindow = new BrowserWindow({
webPreferences: {
@@ -8,16 +14,11 @@ function createWindow () {
}
})
ipcMain.on('set-title', (event, title) => {
const webContents = event.sender
const win = BrowserWindow.fromWebContents(webContents)
win.setTitle(title)
})
mainWindow.loadFile('index.html')
}
app.whenReady().then(() => {
ipcMain.on('set-title', handleSetTitle)
createWindow()
app.on('activate', function () {