通过browserView嵌入两个子窗口,先显示一个a窗口,等b窗口创建完之后关闭a窗口,再显示b窗口
win = new BrowserWindow({
width: 1200,
height: 700,
minWidth: 1200,
minHeight: 700,
webPreferences: {
nodeIntegration: true,
webviewTag: true
}
});
let view = new BrowserView()
win.setBrowserView(view)
view.setBounds({ x: 0, y: 0, width: 1200, height: 700 })
view.webContents.loadURL(url)
let view1 = new BrowserView()
win.setBrowserView(view1)
view1.setBounds({ x: 0, y: 0, width: 1200, height: 700 })
view1.webContents.loadURL(resouce.loadingHtml) // 放在后面的将被显示
view.webContents.on("did-finish-load", () => {
setTimeout(() => {
(view1.webContents as any).destroy()
arr[op].setBrowserView(view) // 需要重新设置
}, 2000);
})