Replies: 1 comment
-
在路由切换时应该注销事件监听,否则就会重复注册, https://github.com/alex8088/electron-toolkit/tree/master/packages/preload const removeListener = window.electron.ipcRenderer.on('electron:reply', (_, args) => {})
removeListener() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
我为主窗口添加了close事件,当其触发时向渲染进程发送quit消息以触发渲染进程中的函数
在preload.js中转发
renderer中的监听函数
结果onAppQuit被执行了两次
vsc terminal:
window console:
这只是最小的现场还原,在我的真实情况中onAppQuit被放在了更深层次的React组件中,它甚至被执行了6次之多。
我尝试把onAppQuit放在React组件之外:
这时候它只被执行了一次。这可能和electron和react的生命周期有关,求指点。
Beta Was this translation helpful? Give feedback.
All reactions