Skip to content

🐞 fix: 修复Mac使用快捷键退出异常#623

Merged
imsyy merged 2 commits intoimsyy:devfrom
Beriholic:dev
Dec 9, 2025
Merged

🐞 fix: 修复Mac使用快捷键退出异常#623
imsyy merged 2 commits intoimsyy:devfrom
Beriholic:dev

Conversation

@Beriholic
Copy link
Copy Markdown
Contributor

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @Beriholic, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求旨在解决在 macOS 系统上使用快捷键退出应用程序时出现的异常行为。通过引入一个退出状态标志并区分应用程序级别的退出事件与窗口关闭事件,确保应用程序在用户通过快捷键(如 Command+Q)退出时能够正确终止,而不是仅仅隐藏窗口。

Highlights

  • Electron app 模块引入: 引入了 Electron 的 app 模块,以便监听应用程序级别的事件。
  • 新增 isQuitting 状态标志: 在 MainWindow 类中添加了一个私有属性 isQuitting,用于追踪应用程序是否正在退出。
  • 处理应用程序退出事件: 监听 appbefore-quit 事件,在该事件触发时将 isQuitting 设为 true
  • 优化窗口关闭逻辑: 修改了主窗口的 close 事件处理逻辑,当 isQuittingtrue 时,允许窗口正常关闭,从而解决 Mac 上使用快捷键退出异常的问题;否则,保持原有的隐藏窗口行为。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

本次 PR 旨在修复在 macOS 上使用快捷键退出应用时出现的异常。您通过引入一个 isQuitting 标志来解决此问题,该标志在应用即将退出时设置。然后在窗口的 close 事件处理程序中使用此标志来决定是真正关闭窗口(当退出应用时)还是仅仅隐藏它(当点击关闭按钮时)。这个方法是正确的,并且解决了问题。我提供了一些建议以提高代码质量和结构,请查阅。

Comment on lines +14 to +16
app.on("before-quit", () => {
this.isQuitting = true;
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

这里添加了一个新的 before-quit 事件监听器。然而,在 electron/main/index.ts 文件中已经存在一个针对此事件的监听器。虽然当前实现能够工作,但为同一个全局应用事件设置多个处理程序来管理相似的状态,会使代码更难理解和维护。更好的做法是集中管理应用生命周期事件。可以考虑将此逻辑移至 electron/main/index.ts 中的 MainProcess,由它来统一处理应用的生命周期,并将退出状态通知给 MainWindow。这将改善代码的关注点分离(Separation of Concerns)。

Comment thread electron/main/windows/main-window.ts Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@imsyy imsyy merged commit 2959737 into imsyy:dev Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants