feat: 支持静默启动(默认托盘运行) - #545
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a 'silent start' (静默启动) feature, allowing the application to start minimized in the system tray without showing the main window by default. This is implemented by adding a setting toggle in the UI, saving/loading the setting, and notifying the main process via a new 'renderer-ready' IPC event once the renderer is ready. The review feedback suggests changing 'ipcMain.on' to 'ipcMain.once' for the 'renderer-ready' event to prevent the window from unexpectedly showing again during page reloads or hot module replacements.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| } | ||
|
|
||
| // 注册 renderer-ready IPC 事件,用于静默启动控制 | ||
| ipcMain.on('renderer-ready', () => { |
There was a problem hiding this comment.
建议将 ipcMain.on 改为 ipcMain.once。
由于渲染进程可能会因为页面刷新、开发环境下的热重载(HMR)或异常重启等原因多次发送 renderer-ready 事件,使用 ipcMain.on 会导致每次渲染进程就绪时都重新触发窗口显示逻辑(在用户关闭了静默启动的情况下)。这可能会在用户已经手动隐藏窗口后,因为页面刷新而导致窗口意外弹出,影响用户体验。
使用 ipcMain.once 可以确保该自动显示逻辑在应用启动时仅执行一次。
| ipcMain.on('renderer-ready', () => { | |
| ipcMain.once('renderer-ready', () => { |
4a5985c to
3576fb1
Compare
Use ipcMain.once for startup show, shorten silent-start copy, and roll back the toggle when save fails.
说明
添加「静默启动」设置:默认启动时不显示主窗口,仅托盘运行;关闭后渲染就绪时自动显示搜索窗口。
原有默认行为(
show: false冷启动)保持不变,本 PR 将其做成可配置项。改动
settings-general.silentStartrenderer-ready,silentStart === false时showWindow()测试