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:
parent
de407e82b7
commit
013133867b
1 changed files with 7 additions and 6 deletions
|
@ -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 () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue