feat(desktop-client): split autostart and keep-alive per platform

Refactors openAtLogin and keepRunningInBackground to make the macOS/Windows
divergence explicit instead of leaning on Electron's cross-platform
abstraction:

- openAtLogin on Windows now passes path: process.execPath and args: []
  so the registry HKCU Run key always points at the right binary.
- keepRunningInBackground on Windows shows a one-shot tray balloon ("省心
  推已最小化到托盘…") so first-time users notice the app is still alive;
  persisted via a private hasShownBackgroundBalloon flag so it never fires
  again. macOS preserves the dock icon and stays silent.
- Sets AppUserModelID early on Windows so tray.displayBalloon's Win10+
  Toast routing actually fires.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-02 18:21:08 +08:00
parent de63d0be5b
commit a4c654782b
3 changed files with 138 additions and 26 deletions
+22
View File
@@ -47,6 +47,28 @@ function formatIssueCount(count: number): string {
return count > 99 ? '99+' : String(count)
}
// Windows-only: tray.displayBalloon shows a system toast next to the tray
// icon. macOS and Linux ignore this call (Electron returns silently), so the
// guard here is just to avoid the no-op log noise on non-Windows.
export function showTrayBalloon(title: string, content: string): void {
if (process.platform !== 'win32') {
return
}
if (!tray || tray.isDestroyed()) {
return
}
try {
tray.displayBalloon({
title,
content,
icon: createTrayIcon('normal'),
iconType: 'custom',
})
} catch (error) {
console.warn('[desktop-tray] displayBalloon failed', error)
}
}
export function updateTrayIssueIndicator(issueCount: number): void {
if (!tray || tray.isDestroyed()) {
return