-
-
Save IrvingZhao/dcf4e98a44a31ebb2d83eb83a4608357 to your computer and use it in GitHub Desktop.
electron window open handle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { app, BrowserWindow } from 'electron' | |
import path from 'path' | |
app.whenReady().then(() => { | |
const mainWindow = new BrowserWindow({ | |
webPreferences: { | |
devTools: true, | |
preload: path.resolve(__dirname, 'preload.js') | |
} | |
}) | |
mainWindow.webContents.setWindowOpenHandler(({ url }) => { | |
if (url === 'about:blank') { | |
return { | |
action: 'allow', | |
overrideBrowserWindowOptions: { | |
frame: false, | |
fullscreenable: false, | |
backgroundColor: 'black', | |
webPreferences: { | |
preload: path.resolve(__dirname, 'preload2.js') | |
} | |
} | |
} | |
} | |
return { action: 'deny' } | |
}) | |
mainWindow.loadURL('about:blank') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment