Open
Conversation
1. dev:kill / dev:electron 脚本使用了 pkill 和 sleep,Windows 不支持, 替换为跨平台的 bun 脚本(scripts/dev-kill.ts、scripts/sleep.ts) 2. electronmon 热重载时在 app.isReady() 之前触发 before-quit, 导致 globalShortcut.unregisterAll() 抛出 uncaught exception(exit code 37), 添加 app.isReady() 守卫修复
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
在 Windows 上执行
bun run dev无法正常启动,存在两个问题:dev:kill/dev:electron脚本不兼容 Windowspkill和sleep是 Unix 命令,Windows 上不存在,导致脚本直接报错退出electronmon 热重载时崩溃(exit code 37)
app.isReady()之前就触发了before-quit事件before-quit中调用globalShortcut.unregisterAll()抛出globalShortcut cannot be used before the app is ready异常uncaught exception occured,应用无法启动修复
scripts/dev-kill.ts:跨平台进程清理,Windows 用taskkill,Unix 用pkillscripts/sleep.ts:跨平台 sleep,用setTimeout实现package.json:dev:kill和dev:electron使用上述跨平台脚本global-shortcut-service.ts:unregisterAllGlobalShortcuts()添加app.isReady()守卫测试
bun run dev正常启动,electronmon 热重载正常