diff --git a/apps/desktop/main/logger.ts b/apps/desktop/main/logger.ts index c947d506..aa965c3f 100644 --- a/apps/desktop/main/logger.ts +++ b/apps/desktop/main/logger.ts @@ -25,9 +25,9 @@ export const logger = { ensureInit() appLogger.warn('app', message) }, - error: (message: string) => { + error: (message: string, data?: unknown) => { ensureInit() - appLogger.error('app', message) + appLogger.error('app', message, data) }, debug: (message: string) => { ensureInit() diff --git a/apps/desktop/main/window/main-window.ts b/apps/desktop/main/window/main-window.ts index 6c457b01..887bdd49 100644 --- a/apps/desktop/main/window/main-window.ts +++ b/apps/desktop/main/window/main-window.ts @@ -93,7 +93,7 @@ function handleWindowsClose(win: BrowserWindow): void { }, quit: requestAppQuit, onError: (error) => { - logger.error(`Failed to handle Windows close request: ${error instanceof Error ? error.message : String(error)}`) + logger.error('Failed to handle Windows close request', error) }, }) } diff --git a/apps/desktop/main/window/titlebar.ts b/apps/desktop/main/window/titlebar.ts index 14ec9475..b160e9a9 100644 --- a/apps/desktop/main/window/titlebar.ts +++ b/apps/desktop/main/window/titlebar.ts @@ -1,28 +1,26 @@ import type { BrowserWindow, TitleBarOverlayOptions } from 'electron' -const TITLE_BAR_OVERLAY_HEIGHT = 32 -const TITLE_BAR_OVERLAY_COLOR = 'rgba(0, 0, 0, 0)' let currentTitleBarOverlayColor: string | null = null const TITLE_BAR_OVERLAY_PALETTE = { - light: { symbolColor: '#52525b' }, - dark: { symbolColor: '#d4d4d8' }, + light: { backgroundColor: '#f9fafb', symbolColor: '#52525b' }, + dark: { backgroundColor: '#111827', symbolColor: '#d4d4d8' }, } as const export function getTitleBarOverlayOptions(isDark: boolean): TitleBarOverlayOptions { const mode = isDark ? 'dark' : 'light' return { - color: TITLE_BAR_OVERLAY_COLOR, + color: getTransparentOverlayColor(TITLE_BAR_OVERLAY_PALETTE[mode].backgroundColor), symbolColor: TITLE_BAR_OVERLAY_PALETTE[mode].symbolColor, - height: TITLE_BAR_OVERLAY_HEIGHT, } } export function getTitleBarOverlayOptionsForColor(color: string): TitleBarOverlayOptions { return { - color: TITLE_BAR_OVERLAY_COLOR, + // Electron derives the minimize/maximize hover color from the overlay RGB. + // Preserve the sampled background channels while keeping the overlay transparent. + color: getTransparentOverlayColor(color), symbolColor: getReadableSymbolColor(color), - height: TITLE_BAR_OVERLAY_HEIGHT, } } @@ -44,6 +42,10 @@ export function resetCurrentTitleBarOverlayColor(): void { currentTitleBarOverlayColor = null } +function getTransparentOverlayColor(color: string): string { + return /^#[0-9a-f]{6}$/i.test(color) ? `${color}00` : 'rgba(0, 0, 0, 0)' +} + function getReadableSymbolColor(hexColor: string): string { const match = /^#([0-9a-f]{6})$/i.exec(hexColor) if (!match) return '#52525b' diff --git a/src/assets/styles/main.css b/src/assets/styles/main.css index f58a5576..3ce011c5 100644 --- a/src/assets/styles/main.css +++ b/src/assets/styles/main.css @@ -69,14 +69,18 @@ /* 标题栏安全区域高度 - 页面顶部 padding 需要避开此区域 * macOS: 红绿灯在左侧由 Sidebar 处理,右侧内容区无遮挡,使用较小值 - * Windows/Linux: 窗口控制按钮在右上角占据 32px 高度,需要完整避开 */ + * Windows: 跟随 Window Controls Overlay 提供的系统高度 + * Linux: 自定义窗口控制按钮固定占据 32px 高度 */ :root { --titlebar-area-height: 1rem; /* 16px - macOS */ } -.platform-windows, +.platform-windows { + --titlebar-area-height: env(titlebar-area-height, 2rem); +} + .platform-linux { - --titlebar-area-height: 2rem; /* 32px - 匹配 titleBarOverlay height */ + --titlebar-area-height: 2rem; } /* 禁用窗口拖拽区域 - 用于弹窗等需要正常交互的元素 */ diff --git a/src/components/common/TitleBar.vue b/src/components/common/TitleBar.vue index cda4faf2..3c5ac125 100644 --- a/src/components/common/TitleBar.vue +++ b/src/components/common/TitleBar.vue @@ -33,7 +33,7 @@ function close() {