Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added build/logo-dev.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 17 additions & 3 deletions src/main/services/WindowService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import windowStateKeeper from 'electron-window-state'
import { join } from 'path'

import iconPath from '../../../build/icon.png?asset'
import logoDevPath from '../../../build/logo-dev.png?asset'
import { titleBarOverlayDark, titleBarOverlayLight } from '../config'
import { configManager } from './ConfigManager'
import { contextMenu } from './ContextMenu'
Expand All @@ -23,8 +24,16 @@ const DEFAULT_MINIWINDOW_HEIGHT = 400
// const logger = loggerService.withContext('WindowService')
const logger = loggerService.withContext('WindowService')

// Create nativeImage for Linux window icon (required for Wayland)
const linuxIcon = isLinux ? nativeImage.createFromPath(iconPath) : undefined
// Window icon for taskbar/title bar — only meaningful on Windows and Linux.
Copy link
Collaborator

@EurFelux EurFelux Mar 13, 2026

Choose a reason for hiding this comment

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

Note

This issue/comment/review was translated by Claude.

But there is no special handling for Windows here, the comment is somewhat misleading.


Original Content 但实际上这里没有对Windows做任何处理,注释有些误导性

// macOS ignores the BrowserWindow `icon` option; dock icon is managed separately via app.dock.setIcon().
// Windows production: icon is embedded in the .exe by electron-builder, no override needed.
function createAppIcon() {
if (isMac) return undefined
if (isDev) return nativeImage.createFromPath(logoDevPath)
Copy link
Collaborator

@GeorgeDong32 GeorgeDong32 Mar 13, 2026

Choose a reason for hiding this comment

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

Note

This comment was translated by Claude.

Issue: Mixed use of isDev and is.dev causes feature to not work

The code mixes two different development mode checks:

  • Line 6 imports isDev from @main/constant
  • Line 4 imports is from @electron-toolkit/utils (which includes is.dev)

isDev only checks NODE_ENV, while is.dev uses more reliable Electron tool detection. Other locations in the file (lines 351, 595) all use is.dev.

Suggestion: Consistently use is.dev

if (is.dev) return nativeImage.createFromPath(logoDevPath)

Original Content

问题:isDevis.dev 混用导致功能不生效

代码中混用了两种不同的开发模式判断:

  • 第6行导入 isDev from @main/constant
  • 第4行导入 is from @electron-toolkit/utils(包含 is.dev

isDev 只检查 NODE_ENV,而 is.dev 使用更可靠的 Electron 工具判断。文件中其他位置(第351、595行)都使用 is.dev

建议: 统一使用 is.dev

if (is.dev) return nativeImage.createFromPath(logoDevPath)

if (isLinux) return nativeImage.createFromPath(iconPath)
return undefined
}
const appIcon = createAppIcon()

export class WindowService {
private static instance: WindowService | null = null
Expand Down Expand Up @@ -83,7 +92,7 @@ export class WindowService {
}),
backgroundColor: isMac ? undefined : nativeTheme.shouldUseDarkColors ? '#181818' : '#FFFFFF',
darkTheme: nativeTheme.shouldUseDarkColors,
...(isLinux ? { icon: linuxIcon } : {}),
...(appIcon ? { icon: appIcon } : {}),
webPreferences: {
preload: join(__dirname, '../preload/index.js'),
sandbox: false,
Expand All @@ -97,6 +106,11 @@ export class WindowService {

this.setupMainWindow(this.mainWindow, mainWindowState)

// Set macOS dock icon in dev mode (production uses the .icns from the app bundle).
Copy link
Collaborator

@GeorgeDong32 GeorgeDong32 Mar 13, 2026

Choose a reason for hiding this comment

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

Note

This issue/comment/review was translated by Claude.

Same issue: should use is.dev instead of isDev

Similar to line 32 above, the isDev check here may be incorrect, causing the macOS Dock icon to not display in development mode.

Suggestion:

if (is.dev && isMac) {
  app.dock?.setIcon(logoDevPath)
}

Original Content

同样的问题:应使用 is.dev 而非 isDev

与上面第32行相同,这里的 isDev 判断可能不正确,导致 macOS Dock 图标在开发模式下无法显示。

建议:

if (is.dev && isMac) {
  app.dock?.setIcon(logoDevPath)
}

if (isDev && isMac) {
app.dock?.setIcon(logoDevPath)
}

//preload miniWindow to resolve series of issues about miniWindow in Mac
const enableQuickAssistant = configManager.getEnableQuickAssistant()
if (enableQuickAssistant && !this.miniWindow) {
Expand Down
Loading