showModalDialog这种形式的,electron不识别。electron有自己的模态实现方式,如下:
const { app, BrowserWindow, ipcMain } = require('electron');
var mainWindow = null;
var flowWindow=null;
app.on('ready', function() {
mainWindow = new BrowserWindow({
width: 1000,
height: 830,
autoHideMenuBar: true,
resizable: true,
webPreferences: {
nodeIntegration: true//默认是false
}
});
mainWindow.webContents.openDevTools();//使可以像浏览器F12一样调试
mainWindow.loadURL('file://' + __dirname + '/app/flow.html');
});
ipcMain.on('open-flow-window', function(){
flowWindow = new BrowserWindow({
parent: mainWindow,
modal: true,
autoHideMenuBar: true,
resizable: true,
webPreferences: {
nodeIntegration: true//默认是false
}
});
flowWindow.webContents.openDevTools();//使可以像浏览器F12一样调试
flowWindow.loadURL('file://' + __dirname + '/app/openFlow.html');
});
mainWindow是主窗口,flowWindow是子窗口,要在子窗口上加上parent: mainWindow和modal: true,轻松实现模态模式窗口