托盘已经做好,并且能在显示器的右下角显示,现在就是不知道点击右上角的红色小叉叉,怎么让窗口隐藏?而且要求双击托盘里的图标后,窗口显示出来
应该操作的是app呢还是mainWindow呢?
托盘已经做好,并且能在显示器的右下角显示,现在就是不知道点击右上角的红色小叉叉,怎么让窗口隐藏?而且要求双击托盘里的图标后,窗口显示出来
应该操作的是app呢还是mainWindow呢?
求助整个流程是怎么实现的,可以详细讲解下嘛,我只简单实现主页面点击关闭按钮,我的托盘也不知道怎么实现。
app.on('window-all-closed', function(){
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});
文档里面有写.
electron/docs/api/browser-window.md
Event: 'close'
Returns:
event Event
Emitted when the window is going to be closed. It's emitted before the beforeunload and unload event of the DOM. Calling event.preventDefault() will cancel the close.
我尝试如下可以解决问题:
// let mainWindow: Electron.BrowserWindow;
mainWindow.on("close", (e:Event) => {
e.preventDefault();
mainWindow.hide();
// 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;
});
// 展示使用 mainWindow.show();
已实现,使用Electron ipcMain 模块可以做到