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

Electron:從 main 調用渲染器函數

Electron: Call renderer function from main(Electron:從 main 調用渲染器函數)
本文介紹了Electron:從 main 調用渲染器函數的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我在本地存儲中有一些數據必須在 app.quit() 上刪除.但我認為從主要過程中無法做到這一點.

I have some data in the localstorage that has to be deleted on app.quit(). But I see no way to do so from the main process.

有沒有辦法從 main 調用 renderer 函數?

Is there a way to call a renderer function from main?

我知道 var remote = require('remote'); 但它似乎只走錯了方向.

I know about var remote = require('remote'); but it seems to go only in the wrong direction.

推薦答案

您可以通過 webContents.send 將消息從主進程發送到渲染器進程,如此處文檔中所述:https://github.com/atom/electron/blob/master/docs/api/web-contents.md#webcontentssendchannel-arg1-arg2-.

You can send messages from the main process to a renderer process via webContents.send as called out in the documentation here: https://github.com/atom/electron/blob/master/docs/api/web-contents.md#webcontentssendchannel-arg1-arg2-.

以下是您直接從文檔中執行此操作的方法:

Here is how you do it straight from the docs:

在主進程中:

// In the main process.
var window = null;
app.on('ready', function() {
  window = new BrowserWindow({width: 800, height: 600});
  window.loadURL('file://' + __dirname + '/index.html');
  window.webContents.on('did-finish-load', function() {
    window.webContents.send('ping', 'whoooooooh!');
  });
});

在 index.html 中:

In index.html:

<!-- index.html -->
<html>
<body>
  <script>
    require('electron').ipcRenderer.on('ping', function(event, message) {
      console.log(message);  // Prints "whoooooooh!"
    });
  </script>
</body>
</html>

注意它是異步的.我不確定這對您的特定解決方案有何影響,但這至少應該讓您與渲染器進程對話.

Note it is asynchronous. I am not sure how that affects things with your particular solution, but this should at least get you talking back to the renderer process.

這篇關于Electron:從 main 調用渲染器函數的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 国产成人精品一区二区 | 小h片免费观看久久久久 | 网络毛片 | 国产一区二区三区免费观看在线 | 91精品久久久久久综合五月天 | 成人一区二区三区视频 | 国产精品jizz在线观看老狼 | 综合激情av | 美女一级a毛片免费观看97 | 亚洲va在线va天堂va狼色在线 | 欧美二区在线 | 婷婷色综合 | 久久久久久国产精品免费免费狐狸 | 中文字幕一区在线观看视频 | 在线91 | 一区二区三区久久久 | 国产精品久久久久久久久久免费看 | 欧美一区二区三区久久精品 | 伊人一区 | 午夜国产| 午夜精品久久久久99蜜 | 亚洲第一免费播放区 | 日韩一区二区在线视频 | 久久久久久久久淑女av国产精品 | 精品国产91乱码一区二区三区 | 亚洲成人精品一区 | 最新国产视频 | 亚洲免费人成在线视频观看 | 国产精品视频免费观看 | 怡红院成人在线视频 | 激情小视频 | 伊人春色成人网 | 欧洲视频一区二区 | 日韩精品在线观看视频 | 91电影| av在线天堂网 | 国产精品视频在线观看 | 中文字幕亚洲免费 | 一区二区三区影院 | 国产精品久久久久久影视 | 国产精品高|