久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

電子:關閉 w X 與右鍵單擊停靠并退出

Electron: Close w X vs right click dock and quit(電子:關閉 w X 與右鍵單擊停靠并退出)
本文介紹了電子:關閉 w X 與右鍵單擊停靠并退出的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

在我的 Electron 應用程序中,我想做一些在其他 OSX 應用程序中經常做的事情.那就是...我不想關閉右上角的紅色 X 的應用程序.但是,如果他們右鍵單擊 Dock 中的應用程序圖標,然后說退出,那么我想退出該應用程序.我該怎么做?

In my Electron app, I would like to do something that is done very often in other OSX apps. That is... I would like to NOT close the app of the red X is clicked in the top right. But, if they right click the app icon in the dock, and say Quit, then I would like to quit the app. How do I do this?

我已經嘗試使用 rendererProcess 中的 onbeforeunload 事件以及 browserWindow.on("close", fn) 事件來嘗試阻止這種情況.問題是他們都提交了 onbeforeunload 事件.而且我無法分辨紅色 X 被單擊和停靠圖標被右鍵單擊并被告知退出之間的區別.你能幫忙的話,我會很高興.有沒有其他人在 Electron for OSX 中這樣做過?

I have tried using the onbeforeunload event from the rendererProcess, as well as the browserWindow.on("close", fn) event to try and prevent this. The problem is that they both file the onbeforeunload event. And I can't tell the different between the red X being clicked and the dock icon being right clicked and told to quit. Any help would be nice. Has anyone else done this in Electron for OSX?

推薦答案

試試這個

if (process.platform === 'darwin') {
  var forceQuit = false;
  app.on('before-quit', function() {
    forceQuit = true;
  });
  mainWindow.on('close', function(event) {
    if (!forceQuit) {
      event.preventDefault();

      /*
       * your process here
       */
    }
  });
}

這篇關于電子:關閉 w X 與右鍵單擊停靠并退出的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 成人a视频在线观看 | 久久精品色欧美aⅴ一区二区 | 国产a级毛片 | 国产伦精品一区二区三区照片91 | 天天精品在线 | 日本黄色短片 | 亚洲永久免费 | www.色.com | 一区二区福利视频 | 日韩国产在线观看 | 午夜精品在线观看 | 国产精品一区在线 | 精品视频一区二区 | 国产乱码精品一区二区三区中文 | 欧美激情精品久久久久久 | 国产va| 成人自拍视频 | 黄a在线播放 | 午夜电影福利 | 日本不卡一区二区 | 天天插天天射天天干 | 欧美精品久久久 | 国产一区二区三区视频在线观看 | 亚洲九九色| 精品国产成人 | 精品一级 | 婷婷久久网 | 日韩欧美一区在线 | 亚洲国产精品一区二区第一页 | 国产精品69av | 国产日韩欧美在线观看 | 久久久久久国产精品免费免费 | 在线欧美一区二区 | 91精品国产91久久综合桃花 | 成人a在线观看 | 日韩一区二区在线看 | 久久久久久网站 | 免费在线观看黄视频 | 免费高清av | aaaa一级毛片| 91av在线免费|