How to pass parameters from main process to render processes in Electron

前端 未结 7 987
隐瞒了意图╮
隐瞒了意图╮ 2021-02-13 02:30

I have an Electron app that can open different windows.

On app launch the app open a set of window(s) (that load the same HTML and JS files) but with params to change ea

7条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-13 02:49

    We can inject Javascript code execution (on window did-finish-load event) and trigger react re-rendering with correct redux state portion. But it requires additional lifecycle step in rendered process.

    Using hash or query in "local filepath" sounds a little bit weird but in my case it take sense since the hash describe the redux store branch to take in consideration in this window (file://which-code-to-load#which-content).

    So even if i'm not totally at ease with this approach right now I'll take the second option.

    It's a shame that the API doesn't provide any way to declare global vars from main process on window opening. I'll post a feature request.

提交回复
热议问题