mirror of
https://github.com/electron/electron.git
synced 2026-01-09 15:38:08 -05:00
refactor: use ipcRenderer.invoke / ipcMain.handle in default-app (#18581)
This commit is contained in:
committed by
Alexey Kuzmin
parent
74825e4df7
commit
69e32ad9ce
@@ -37,12 +37,8 @@ function isTrustedSender (webContents: Electron.WebContents) {
|
|||||||
return parsedUrl.protocol === 'file:' && urlPath === indexPath
|
return parsedUrl.protocol === 'file:' && urlPath === indexPath
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcMain.on('bootstrap', (event) => {
|
ipcMain.handle('bootstrap', (event) => {
|
||||||
try {
|
return isTrustedSender(event.sender) ? electronPath : null
|
||||||
event.returnValue = isTrustedSender(event.sender) ? electronPath : null
|
|
||||||
} catch {
|
|
||||||
event.returnValue = null
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
async function createWindow () {
|
async function createWindow () {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ipcRenderer } from 'electron'
|
import { ipcRenderer } from 'electron'
|
||||||
|
|
||||||
function initialize () {
|
async function initialize () {
|
||||||
const electronPath = ipcRenderer.sendSync('bootstrap')
|
const electronPath = await ipcRenderer.invoke('bootstrap')
|
||||||
|
|
||||||
function replaceText (selector: string, text: string) {
|
function replaceText (selector: string, text: string) {
|
||||||
const element = document.querySelector<HTMLElement>(selector)
|
const element = document.querySelector<HTMLElement>(selector)
|
||||||
|
|||||||
Reference in New Issue
Block a user