webpack+electron(桌面系统双平系统)

新建屏幕

function createWindow() {

mainWindow = new BrowserWindow({
    webPreferences: {
        webSecurity: false
    },
    width: 1024,
    height: 768,
    icon: 'static/icon.ico',
    transparent: false,
    frame: false,
    minimizable: true,
    titleBarStyle: 'hiddenInset'
})
mainWindow.once('ready-to-show', () => {
    mainWindow.show()
})
let displays = electron.screen.getAllDisplays()
let externalDisplay = displays.find((display) => {
    return display.bounds.x !== 0 || display.bounds.y !== 0
})

if(externalDisplay) {
    win = new BrowserWindow({
        width: 1024,
        height: 768,
        transparent: false,
        frame: false,
        x: externalDisplay.bounds.x,
        y: externalDisplay.bounds.y,
        closable: true,    //是否可以关闭
        skipTaskbar: true //不显示在任务栏
    })
    win.once('ready-to-show', () => {
        win.show()
    })
    win.loadURL(`file://${__dirname}/pingmuad.html`)
    //设置全屏
    win.setFullScreen(true);

}
//设置全屏
mainWindow.setFullScreen(true);
// and load the index.html of the app.
mainWindow.loadURL(url.format({
    pathname: path.join(__dirname, 'index.html'),
    protocol: 'file:',
    slashes: true
}))
trayIcon = path.join(__dirname, 'static');
appTray = new Tray(path.join(trayIcon, 'icon.ico'));
// Open the DevTools.
mainWindow.webContents.openDevTools();
// Emitted when the window is closed.
    mainWindow.on('closed', function() {
        // Dereference the window object, usually you would store windows
        // in an array if your app supports multi windows, this is the time
        // when you should delete the corresponding element.
        mainWindow = null;
        app.quit()
    })

}
开启第二块平面
ipc.on("pingmuorder", (event, arg) => {

win.loadURL(`file://${__dirname}/pingmuorder.html`);
win.setMenu(null);
win.webContents.on('did-finish-load', () => {
    win.webContents.send('request', arg);
});

});

准备启动项目
app.on('ready', createWindow)

关闭屏幕退出
app.on('window-all-closed', function() {

if(process.platform !== 'darwin') {
    app.quit()
}

})

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值