fix: app can't be restarted successfully when the application has interactive behavior that prevents closing (such as a confirmation dialog box).
Additional context
The code that may trigger the bug:
mainWindow.on('close', (e) => {
dialog.showMessageBox({
title: 'App Shutdown Notice',
message: 'Are you sure to shutdown the application?',
type: 'info',
buttons: ['Ignore', 'Exit'],
})
.then((result) => {
if (result.response === 1)
app.quit()
})
})
The solution:
const watchHook = (): void => {
logger.info(colors.green(`\nrebuild the electron main process successfully`))
if (ps) {
logger.info(colors.cyan(`\n waiting for electron to exit...`))
ps.removeAllListeners()
ps.on('exit', () => {
ps = startElectron(inlineConfig.root)
logger.info(colors.green(`\nrestart electron app...`))
})
ps.kill()
}
}
In this code, I added an exit event listener, which starts a new Electron process after the old Electron process exits. This ensures that the new Electron process starts only after the old Electron process has completely exited.
What is the purpose of this pull request?
[X] Bug fix
[ ] New Feature
[ ] Documentation update
[ ] Other
Before submitting the PR, please make sure you do the following
Description
fix: app can't be restarted successfully when the application has interactive behavior that prevents closing (such as a confirmation dialog box).
Additional context
The code that may trigger the bug:
The solution:
In this code, I added an exit event listener, which starts a new Electron process after the old Electron process exits. This ensures that the new Electron process starts only after the old Electron process has completely exited.
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).