1- import { app , BrowserWindow , Menu , screen , shell } from 'electron'
1+ import { app , BrowserWindow , Menu , nativeTheme , screen , shell } from 'electron'
22import { join } from 'path'
33import { existsSync } from 'fs'
44
@@ -15,6 +15,7 @@ if (!app.requestSingleInstanceLock()) {
1515}
1616
1717import { getSettings } from './lib/settings-service'
18+ import { resolveOverlayColors } from './lib/titlebar-overlay'
1819
1920// 处理 EPIPE 错误:当 stdout/stderr 管道被关闭时(如 electronmon 重启),忽略写入错误
2021// 这在开发环境热重载时经常发生,不影响应用功能
@@ -163,22 +164,43 @@ function createWindow(): void {
163164 console . warn ( 'App icon not found at:' , iconPath )
164165 }
165166
167+ const isMac = process . platform === 'darwin'
168+ const isWindows = process . platform === 'win32'
169+
170+ const titleBarOptions = isMac
171+ ? {
172+ titleBarStyle : 'hiddenInset' as const ,
173+ trafficLightPosition : { x : 18 , y : 18 } ,
174+ vibrancy : 'under-window' as const ,
175+ visualEffectState : 'followWindow' as const ,
176+ }
177+ : isWindows
178+ ? ( ( ) => {
179+ const settings = getSettings ( )
180+ return {
181+ titleBarStyle : 'hidden' as const ,
182+ titleBarOverlay : resolveOverlayColors (
183+ settings . themeMode ,
184+ settings . themeStyle ,
185+ nativeTheme . shouldUseDarkColors
186+ ) ,
187+ }
188+ } ) ( )
189+ : { }
190+
166191 mainWindow = new BrowserWindow ( {
167192 width : 1400 ,
168193 height : 900 ,
169194 minWidth : 800 ,
170195 minHeight : 600 ,
171196 icon : iconExists ? iconPath : undefined ,
172- show : false , // Don't show until ready
197+ show : false ,
173198 webPreferences : {
174199 preload : join ( __dirname , 'preload.cjs' ) ,
175200 contextIsolation : true ,
176201 nodeIntegration : false ,
177202 } ,
178- titleBarStyle : 'hiddenInset' , // macOS style
179- trafficLightPosition : { x : 18 , y : 18 } ,
180- vibrancy : 'under-window' , // macOS glass effect
181- visualEffectState : 'followWindow' ,
203+ ...titleBarOptions ,
182204 } )
183205
184206 // Load the renderer
0 commit comments