Skip to content

Commit f4f61c4

Browse files
feat(windows): improve native Windows appearance and theme support (#1114)
Co-authored-by: Wendong-Fan <w3ndong.fan@gmail.com> Co-authored-by: Wendong-Fan <133094783+Wendong-Fan@users.noreply.github.com>
1 parent cdc8ad2 commit f4f61c4

3 files changed

Lines changed: 35 additions & 11 deletions

File tree

electron/main/index.ts

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,13 @@ protocol.registerSchemesAsPrivileged([
167167
process.env.APP_ROOT = MAIN_DIST;
168168
process.env.VITE_PUBLIC = VITE_PUBLIC;
169169

170-
// Disable system theme
171-
nativeTheme.themeSource = 'light';
170+
// Respect system theme on Windows, keep light theme on macOS for consistency
171+
const isWindows = process.platform === 'win32';
172+
if (isWindows) {
173+
nativeTheme.themeSource = 'system'; // Respect Windows dark/light mode
174+
} else {
175+
nativeTheme.themeSource = 'light'; // Keep existing behavior for macOS
176+
}
172177

173178
// Set log level
174179
log.transports.console.level = 'info';
@@ -1281,22 +1286,37 @@ async function createWindow() {
12811286
)}`
12821287
);
12831288

1289+
// Platform-specific window configuration
1290+
// Windows: Use native frame for better native feel, solid background
1291+
// macOS: Use frameless with transparency and vibrancy effects
12841292
win = new BrowserWindow({
12851293
title: 'Eigent',
12861294
width: 1200,
12871295
height: 800,
12881296
minWidth: 1050,
12891297
minHeight: 650,
1290-
frame: false,
1298+
// Use native frame on Windows for better native integration
1299+
frame: isWindows ? true : false,
12911300
show: false, // Don't show until content is ready to avoid white screen
1292-
transparent: true,
1293-
vibrancy: 'sidebar',
1294-
visualEffectState: 'active',
1295-
backgroundColor: '#f5f5f580',
1301+
// Only use transparency on macOS and Linux (not supported well on Windows)
1302+
transparent: !isWindows,
1303+
// macOS-only visual effects
1304+
vibrancy: isMac ? 'sidebar' : undefined,
1305+
visualEffectState: isMac ? 'active' : undefined,
1306+
// Solid background on Windows (respect dark/light mode), semi-transparent on macOS/Linux
1307+
backgroundColor: isWindows
1308+
? (nativeTheme.shouldUseDarkColors ? '#1e1e1e' : '#ffffff')
1309+
: '#f5f5f580',
1310+
// macOS-specific title bar styling
12961311
titleBarStyle: isMac ? 'hidden' : undefined,
12971312
trafficLightPosition: isMac ? { x: 10, y: 10 } : undefined,
12981313
icon: path.join(VITE_PUBLIC, 'favicon.ico'),
1299-
roundedCorners: true,
1314+
// Rounded corners on macOS and Linux (as original)
1315+
roundedCorners: !isWindows,
1316+
// Windows-specific options
1317+
...(isWindows && {
1318+
autoHideMenuBar: true, // Hide menu bar on Windows for cleaner look
1319+
}),
13001320
webPreferences: {
13011321
// Use a dedicated partition for main window to isolate from webviews
13021322
// This ensures main window's auth data (localStorage) is stored separately and persists across restarts

src/components/TopBar/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ function HeaderWin() {
368368
</div>
369369
)}
370370
</div>
371-
{platform !== "darwin" && (
371+
{/* Custom window controls only for Linux (Windows and macOS use native controls) */}
372+
{platform !== "darwin" && platform !== "win32" && (
372373
<div
373374
className="h-full flex items-center no-drag"
374375
id="window-controls"

src/components/WindowControls/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,17 @@ export default function WindowControls() {
2424
const p = window.electronAPI.getPlatform();
2525
setPlatform(p);
2626

27-
if (p === "darwin") {
27+
// Hide custom controls on macOS (uses native traffic lights)
28+
// and on Windows (now uses native frame with native controls)
29+
if (p === "darwin" || p === "win32") {
2830
if (controlsRef.current) {
2931
controlsRef.current.style.display = "none";
3032
}
3133
}
3234
}, []);
3335

34-
if (platform === "darwin") {
36+
// Don't render custom controls on macOS or Windows (both use native controls)
37+
if (platform === "darwin" || platform === "win32") {
3538
return null;
3639
}
3740

0 commit comments

Comments
 (0)