久久久久久久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?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 久久久不卡网国产精品一区 | 日韩伦理一区二区三区 | 国产日韩精品视频 | 久久综合伊人一区二区三 | 成人毛片在线观看 | 欧美日一区二区 | 国产精品成av人在线视午夜片 | 日产精品久久久一区二区福利 | 久久久久久久久久久久久久国产 | 麻豆av一区二区三区久久 | 国产成人艳妇aa视频在线 | 在线国产视频 | 日韩精彩视频 | 欧美一级免费 | 四虎成人精品永久免费av九九 | 免费麻豆视频 | 欧美日韩大片 | 欧美一级毛片在线播放 | 九九99久久 | 超碰免费在线 | 在线观看中文视频 | 精品成人 | 亚洲入口 | 中文字幕欧美一区 | 免费毛片www com cn | 成人二区 | 日本黄色免费视频 | 一级a爱片性色毛片免费 | 日本不卡一区二区三区 | 免费午夜电影 | 亚洲免费在线观看 | 日韩精品一区二区三区在线播放 | 久久国产高清视频 | 国产精品久久久久久中文字 | 精品99久久 | 日韩视频在线播放 | 99久久免费精品国产男女高不卡 | 国产欧美精品区一区二区三区 | 亚洲一区二区久久 | 久久国产精品免费 | 国产精品国产精品国产专区不片 |