🐛 fix(desktop): remove electron-liquid-glass to fix click event blocking (#13070)

* 🐛 fix(desktop): remove electron-liquid-glass to fix click event blocking

The electron-liquid-glass native addon was blocking all click events in the
Electron desktop app window. Remove the dependency and restore vibrancy-based
transparency with semi-transparent body background via `.desktop` CSS class.

* 🔨 chore(desktop): remove electron-liquid-glass from native modules config
This commit is contained in:
Innei
2026-03-17 22:56:29 +08:00
committed by GitHub
parent f8d51bbf4f
commit 4994d19a9c
8 changed files with 47 additions and 109 deletions

View File

@@ -1,15 +1,9 @@
<!doctype html>
<html>
<html class="desktop">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
html body {
background: #f8f8f8;
}
html[data-theme='dark'] body {
background-color: #000;
}
#loading-screen {
position: fixed;
inset: 0;
@@ -22,12 +16,20 @@
gap: 12px;
}
@keyframes loading-draw {
0% { stroke-dashoffset: 1000; }
100% { stroke-dashoffset: 0; }
0% {
stroke-dashoffset: 1000;
}
100% {
stroke-dashoffset: 0;
}
}
@keyframes loading-fill {
30% { fill-opacity: 0.05; }
100% { fill-opacity: 1; }
30% {
fill-opacity: 0.05;
}
100% {
fill-opacity: 1;
}
}
#loading-brand {
display: flex;
@@ -75,13 +77,22 @@
</script>
<div id="loading-screen">
<div id="loading-brand" aria-label="Loading" role="status">
<svg fill="currentColor" fill-rule="evenodd" height="40" style="flex:none;line-height:1" viewBox="0 0 940 320" xmlns="http://www.w3.org/2000/svg">
<svg
fill="currentColor"
fill-rule="evenodd"
height="40"
style="flex: none; line-height: 1"
viewBox="0 0 940 320"
xmlns="http://www.w3.org/2000/svg"
>
<title>LobeHub</title>
<path d="M15 240.035V87.172h39.24V205.75h66.192v34.285H15zM183.731 242c-11.759 0-22.196-2.621-31.313-7.862-9.116-5.241-16.317-12.447-21.601-21.619-5.153-9.317-7.729-19.945-7.729-31.883 0-11.937 2.576-22.492 7.729-31.664 5.164-8.963 12.159-15.98 20.982-21.05l.619-.351c9.117-5.241 19.554-7.861 31.313-7.861s22.196 2.62 31.313 7.861c9.248 5.096 16.449 12.229 21.601 21.401 5.153 9.172 7.729 19.727 7.729 31.664 0 11.938-2.576 22.566-7.729 31.883-5.152 9.172-12.353 16.378-21.601 21.619-9.117 5.241-19.554 7.862-31.313 7.862zm0-32.975c4.36 0 8.191-1.092 11.494-3.275 3.436-2.184 6.144-5.387 8.126-9.609 1.982-4.367 2.973-9.536 2.973-15.505 0-5.968-.991-10.991-2.973-15.067-1.906-4.06-4.483-7.177-7.733-9.352l-.393-.257c-3.303-2.184-7.134-3.276-11.494-3.276-4.228 0-8.059 1.092-11.495 3.276-3.303 2.184-6.011 5.387-8.125 9.609-1.982 4.076-2.973 9.099-2.973 15.067 0 5.969.991 11.138 2.973 15.505 2.114 4.222 4.822 7.425 8.125 9.609 3.436 2.183 7.267 3.275 11.495 3.275zM295.508 78l-.001 54.042a34.071 34.071 0 016.541-5.781c6.474-4.367 14.269-6.551 23.385-6.551 9.777 0 18.629 2.475 26.557 7.424 7.872 4.835 14.105 11.684 18.7 20.546l.325.637c4.756 9.026 7.135 19.799 7.135 32.319 0 12.666-2.379 23.585-7.135 32.757-4.624 9.026-10.966 16.087-19.025 21.182-7.928 4.95-16.78 7.425-26.557 7.425-9.644 0-17.704-2.184-24.178-6.551-2.825-1.946-5.336-4.355-7.532-7.226l.001 11.812h-35.87V78h37.654zm21.998 74.684c-4.228 0-8.059 1.092-11.494 3.276-3.303 2.184-6.012 5.387-8.126 9.609-1.982 4.076-2.972 9.099-2.972 15.067 0 5.969.99 11.138 2.972 15.505 2.114 4.222 4.823 7.425 8.126 9.609 3.435 2.183 7.266 3.275 11.494 3.275s7.994-1.092 11.297-3.275c3.435-2.184 6.143-5.387 8.125-9.609 2.114-4.367 3.171-9.536 3.171-15.505 0-5.968-1.057-10.991-3.171-15.067-1.906-4.06-4.483-7.177-7.732-9.352l-.393-.257c-3.303-2.184-7.069-3.276-11.297-3.276zm105.335 38.653l.084.337a27.857 27.857 0 002.057 5.559c2.246 4.222 5.417 7.498 9.513 9.827 4.096 2.184 8.984 3.276 14.665 3.276 5.285 0 9.777-.801 13.477-2.403 3.579-1.632 7.1-4.025 10.564-7.182l.732-.679 19.818 22.711c-5.153 6.26-11.494 11.064-19.025 14.413-7.531 3.203-16.449 4.804-26.755 4.804-12.683 0-23.782-2.621-33.294-7.862-9.381-5.386-16.713-12.665-21.998-21.837-5.153-9.317-7.729-19.872-7.729-31.665 0-11.792 2.51-22.274 7.53-31.446 5.036-9.105 11.902-16.195 20.596-21.268l.61-.351c8.984-5.241 19.091-7.861 30.322-7.861 10.311 0 19.743 2.286 28.294 6.859l.64.347c8.72 4.659 15.656 11.574 20.809 20.746 5.153 9.172 7.729 20.309 7.729 33.411 0 1.294-.052 2.761-.156 4.4l-.042.623-.17 2.353c-.075 1.01-.151 1.973-.227 2.888h-78.044zm21.365-42.147c-4.492 0-8.456 1.092-11.891 3.276-3.303 2.184-5.879 5.314-7.729 9.39a26.04 26.04 0 00-1.117 2.79 30.164 30.164 0 00-1.121 4.499l-.058.354h43.96l-.015-.106c-.401-2.638-1.122-5.055-2.163-7.252l-.246-.503c-1.776-3.774-4.282-6.742-7.519-8.906l-.409-.266c-3.303-2.184-7.2-3.276-11.692-3.276zm111.695-62.018l-.001 57.432h53.51V87.172h39.24v152.863h-39.24v-59.617H555.9l.001 59.617h-39.24V87.172h39.24zM715.766 242c-8.72 0-16.581-1.893-23.583-5.678-6.87-3.785-12.287-9.681-16.251-17.688-3.832-8.153-5.747-18.417-5.747-30.791v-66.168h37.654v59.398c0 9.172 1.519 15.723 4.558 19.654 3.171 3.931 7.597 5.896 13.278 5.896 3.7 0 7.069-.946 10.108-2.839 3.038-1.892 5.483-4.877 7.332-8.953 1.85-4.222 2.775-9.609 2.775-16.16v-56.996h37.654v118.36h-35.871l.004-12.38c-2.642 3.197-5.682 5.868-9.12 8.012-7.002 4.222-14.599 6.333-22.791 6.333zM841.489 78l-.001 54.041a34.1 34.1 0 016.541-5.78c6.474-4.367 14.269-6.551 23.385-6.551 9.777 0 18.629 2.475 26.556 7.424 7.873 4.835 14.106 11.684 18.701 20.546l.325.637c4.756 9.026 7.134 19.799 7.134 32.319 0 12.666-2.378 23.585-7.134 32.757-4.624 9.026-10.966 16.087-19.026 21.182-7.927 4.95-16.779 7.425-26.556 7.425-9.645 0-17.704-2.184-24.178-6.551-2.825-1.946-5.336-4.354-7.531-7.224v11.81h-35.87V78h37.654zm21.998 74.684c-4.228 0-8.059 1.092-11.495 3.276-3.303 2.184-6.011 5.387-8.125 9.609-1.982 4.076-2.973 9.099-2.973 15.067 0 5.969.991 11.138 2.973 15.505 2.114 4.222 4.822 7.425 8.125 9.609 3.436 2.183 7.267 3.275 11.495 3.275 4.228 0 7.993-1.092 11.296-3.275 3.435-2.184 6.144-5.387 8.126-9.609 2.114-4.367 3.171-9.536 3.171-15.505 0-5.968-1.057-10.991-3.171-15.067-1.906-4.06-4.484-7.177-7.733-9.352l-.393-.257c-3.303-2.184-7.068-3.276-11.296-3.276z" />
<path
d="M15 240.035V87.172h39.24V205.75h66.192v34.285H15zM183.731 242c-11.759 0-22.196-2.621-31.313-7.862-9.116-5.241-16.317-12.447-21.601-21.619-5.153-9.317-7.729-19.945-7.729-31.883 0-11.937 2.576-22.492 7.729-31.664 5.164-8.963 12.159-15.98 20.982-21.05l.619-.351c9.117-5.241 19.554-7.861 31.313-7.861s22.196 2.62 31.313 7.861c9.248 5.096 16.449 12.229 21.601 21.401 5.153 9.172 7.729 19.727 7.729 31.664 0 11.938-2.576 22.566-7.729 31.883-5.152 9.172-12.353 16.378-21.601 21.619-9.117 5.241-19.554 7.862-31.313 7.862zm0-32.975c4.36 0 8.191-1.092 11.494-3.275 3.436-2.184 6.144-5.387 8.126-9.609 1.982-4.367 2.973-9.536 2.973-15.505 0-5.968-.991-10.991-2.973-15.067-1.906-4.06-4.483-7.177-7.733-9.352l-.393-.257c-3.303-2.184-7.134-3.276-11.494-3.276-4.228 0-8.059 1.092-11.495 3.276-3.303 2.184-6.011 5.387-8.125 9.609-1.982 4.076-2.973 9.099-2.973 15.067 0 5.969.991 11.138 2.973 15.505 2.114 4.222 4.822 7.425 8.125 9.609 3.436 2.183 7.267 3.275 11.495 3.275zM295.508 78l-.001 54.042a34.071 34.071 0 016.541-5.781c6.474-4.367 14.269-6.551 23.385-6.551 9.777 0 18.629 2.475 26.557 7.424 7.872 4.835 14.105 11.684 18.7 20.546l.325.637c4.756 9.026 7.135 19.799 7.135 32.319 0 12.666-2.379 23.585-7.135 32.757-4.624 9.026-10.966 16.087-19.025 21.182-7.928 4.95-16.78 7.425-26.557 7.425-9.644 0-17.704-2.184-24.178-6.551-2.825-1.946-5.336-4.355-7.532-7.226l.001 11.812h-35.87V78h37.654zm21.998 74.684c-4.228 0-8.059 1.092-11.494 3.276-3.303 2.184-6.012 5.387-8.126 9.609-1.982 4.076-2.972 9.099-2.972 15.067 0 5.969.99 11.138 2.972 15.505 2.114 4.222 4.823 7.425 8.126 9.609 3.435 2.183 7.266 3.275 11.494 3.275s7.994-1.092 11.297-3.275c3.435-2.184 6.143-5.387 8.125-9.609 2.114-4.367 3.171-9.536 3.171-15.505 0-5.968-1.057-10.991-3.171-15.067-1.906-4.06-4.483-7.177-7.732-9.352l-.393-.257c-3.303-2.184-7.069-3.276-11.297-3.276zm105.335 38.653l.084.337a27.857 27.857 0 002.057 5.559c2.246 4.222 5.417 7.498 9.513 9.827 4.096 2.184 8.984 3.276 14.665 3.276 5.285 0 9.777-.801 13.477-2.403 3.579-1.632 7.1-4.025 10.564-7.182l.732-.679 19.818 22.711c-5.153 6.26-11.494 11.064-19.025 14.413-7.531 3.203-16.449 4.804-26.755 4.804-12.683 0-23.782-2.621-33.294-7.862-9.381-5.386-16.713-12.665-21.998-21.837-5.153-9.317-7.729-19.872-7.729-31.665 0-11.792 2.51-22.274 7.53-31.446 5.036-9.105 11.902-16.195 20.596-21.268l.61-.351c8.984-5.241 19.091-7.861 30.322-7.861 10.311 0 19.743 2.286 28.294 6.859l.64.347c8.72 4.659 15.656 11.574 20.809 20.746 5.153 9.172 7.729 20.309 7.729 33.411 0 1.294-.052 2.761-.156 4.4l-.042.623-.17 2.353c-.075 1.01-.151 1.973-.227 2.888h-78.044zm21.365-42.147c-4.492 0-8.456 1.092-11.891 3.276-3.303 2.184-5.879 5.314-7.729 9.39a26.04 26.04 0 00-1.117 2.79 30.164 30.164 0 00-1.121 4.499l-.058.354h43.96l-.015-.106c-.401-2.638-1.122-5.055-2.163-7.252l-.246-.503c-1.776-3.774-4.282-6.742-7.519-8.906l-.409-.266c-3.303-2.184-7.2-3.276-11.692-3.276zm111.695-62.018l-.001 57.432h53.51V87.172h39.24v152.863h-39.24v-59.617H555.9l.001 59.617h-39.24V87.172h39.24zM715.766 242c-8.72 0-16.581-1.893-23.583-5.678-6.87-3.785-12.287-9.681-16.251-17.688-3.832-8.153-5.747-18.417-5.747-30.791v-66.168h37.654v59.398c0 9.172 1.519 15.723 4.558 19.654 3.171 3.931 7.597 5.896 13.278 5.896 3.7 0 7.069-.946 10.108-2.839 3.038-1.892 5.483-4.877 7.332-8.953 1.85-4.222 2.775-9.609 2.775-16.16v-56.996h37.654v118.36h-35.871l.004-12.38c-2.642 3.197-5.682 5.868-9.12 8.012-7.002 4.222-14.599 6.333-22.791 6.333zM841.489 78l-.001 54.041a34.1 34.1 0 016.541-5.78c6.474-4.367 14.269-6.551 23.385-6.551 9.777 0 18.629 2.475 26.556 7.424 7.873 4.835 14.106 11.684 18.701 20.546l.325.637c4.756 9.026 7.134 19.799 7.134 32.319 0 12.666-2.378 23.585-7.134 32.757-4.624 9.026-10.966 16.087-19.026 21.182-7.927 4.95-16.779 7.425-26.556 7.425-9.645 0-17.704-2.184-24.178-6.551-2.825-1.946-5.336-4.354-7.531-7.224v11.81h-35.87V78h37.654zm21.998 74.684c-4.228 0-8.059 1.092-11.495 3.276-3.303 2.184-6.011 5.387-8.125 9.609-1.982 4.076-2.973 9.099-2.973 15.067 0 5.969.991 11.138 2.973 15.505 2.114 4.222 4.822 7.425 8.125 9.609 3.436 2.183 7.267 3.275 11.495 3.275 4.228 0 7.993-1.092 11.296-3.275 3.435-2.184 6.144-5.387 8.126-9.609 2.114-4.367 3.171-9.536 3.171-15.505 0-5.968-1.057-10.991-3.171-15.067-1.906-4.06-4.484-7.177-7.733-9.352l-.393-.257c-3.303-2.184-7.068-3.276-11.296-3.276z"
/>
</svg>
</div>
</div>
<div id="root" style="height: 100%;"></div>
<div id="root" style="height: 100%"></div>
<script>
window.__SERVER_CONFIG__ = undefined;
</script>

View File

@@ -1,3 +1,4 @@
/* eslint-disable no-console */
/**
* Native dependencies configuration for Electron build
*
@@ -33,7 +34,7 @@ const isDarwin = getTargetPlatform() === 'darwin';
*/
export const nativeModules = [
// macOS-only native modules
...(isDarwin ? ['node-mac-permissions', 'electron-liquid-glass'] : []),
...(isDarwin ? ['node-mac-permissions'] : []),
'@napi-rs/canvas',
// Add more native modules here as needed
];

View File

@@ -41,8 +41,7 @@
"update-server": "sh scripts/update-test/run-test.sh"
},
"dependencies": {
"@napi-rs/canvas": "^0.1.70",
"electron-liquid-glass": "^1.1.1"
"@napi-rs/canvas": "^0.1.70"
},
"devDependencies": {
"@electron-toolkit/eslint-config-prettier": "^3.0.0",
@@ -68,9 +67,9 @@
"cookie": "^1.1.1",
"cross-env": "^10.1.0",
"diff": "^8.0.2",
"electron": "^38.7.2",
"electron-builder": "^26.0.12",
"electron-devtools-installer": "^3.2.0",
"electron": "41.0.2",
"electron-builder": "^26.8.1",
"electron-devtools-installer": "4.0.0",
"electron-is": "^3.0.0",
"electron-log": "^5.4.3",
"electron-store": "^8.2.0",

View File

@@ -154,7 +154,7 @@ export default class Browser {
private setupWindow(browserWindow: BrowserWindow): void {
logger.debug(`[${this.identifier}] BrowserWindow instance created.`);
// Setup theme management (includes liquid glass lifecycle on macOS Tahoe)
// Setup theme management
this.themeManager.attach(browserWindow);
// Setup network interceptors
@@ -167,7 +167,7 @@ export default class Browser {
// Setup devtools if enabled
if (this.options.devTools) {
logger.debug(`[${this.identifier}] Opening DevTools.`);
browserWindow.webContents.openDevTools();
browserWindow.webContents.openDevTools({ mode: 'detach' });
}
// Setup event listeners

View File

@@ -4,7 +4,7 @@ import { TITLE_BAR_HEIGHT } from '@lobechat/desktop-bridge';
import { type BrowserWindow, type BrowserWindowConstructorOptions, nativeTheme } from 'electron';
import { buildDir } from '@/const/dir';
import { isDev, isLinux, isMac, isMacTahoe, isWindows } from '@/const/env';
import { isDev, isLinux, isMac, isWindows } from '@/const/env';
import { createLogger } from '@/utils/logger';
import {
@@ -33,19 +33,6 @@ interface LinuxThemeConfig {
hasShadow: true;
}
// Lazy-load liquid glass only on macOS Tahoe to avoid import errors on other platforms.
// Dynamic require is intentional: native .node addons cannot be loaded via
// async import() and must be synchronously required at module init time.
// eslint-disable-next-line @typescript-eslint/consistent-type-imports -- dynamic require, type from module
let liquidGlass: typeof import('electron-liquid-glass').default | undefined;
if (isMacTahoe) {
try {
liquidGlass = require('electron-liquid-glass');
} catch {
// Native module not available (e.g. wrong architecture or missing binary)
}
}
/**
* Manages window theme configuration and visual effects
*/
@@ -54,7 +41,6 @@ export class WindowThemeManager {
private browserWindow?: BrowserWindow;
private listenerSetup = false;
private boundHandleThemeChange: () => void;
private liquidGlassViewId?: number;
constructor(identifier: string) {
this.identifier = identifier;
@@ -74,20 +60,11 @@ export class WindowThemeManager {
/**
* Attach to a browser window and setup theme handling.
* Owns the full visual effect lifecycle including liquid glass on macOS Tahoe.
*/
attach(browserWindow: BrowserWindow): void {
this.browserWindow = browserWindow;
this.setupThemeListener();
this.applyVisualEffects();
// Liquid glass must be applied after window content loads (native view needs
// a rendered surface). The effect persists across subsequent in-window navigations.
if (this.useLiquidGlass) {
browserWindow.webContents.once('did-finish-load', () => {
this.applyLiquidGlass();
});
}
}
/**
@@ -99,7 +76,6 @@ export class WindowThemeManager {
this.listenerSetup = false;
logger.debug(`[${this.identifier}] Theme listener cleaned up.`);
}
this.liquidGlassViewId = undefined;
this.browserWindow = undefined;
}
@@ -112,13 +88,6 @@ export class WindowThemeManager {
return nativeTheme.shouldUseDarkColors;
}
/**
* Whether liquid glass is available and should be used
*/
get useLiquidGlass(): boolean {
return isMacTahoe && !!liquidGlass;
}
/**
* Get platform-specific theme configuration for window creation
*/
@@ -131,14 +100,6 @@ export class WindowThemeManager {
// Traffic light buttons are approximately 12px tall
const trafficLightY = Math.round((TITLE_BAR_HEIGHT - 12) / 2);
if (this.useLiquidGlass) {
// Liquid glass requires transparent window and must NOT use vibrancy — they conflict.
return {
trafficLightPosition: { x: 12, y: trafficLightY },
transparent: true,
};
}
return {
trafficLightPosition: { x: 12, y: trafficLightY },
vibrancy: 'sidebar',
@@ -224,8 +185,6 @@ export class WindowThemeManager {
this.applyWindowsVisualEffects(isDarkMode);
} else if (isLinux) {
this.applyLinuxVisualEffects();
} else if (isMac) {
this.applyMacVisualEffects();
}
} catch (error) {
logger.error(`[${this.identifier}] Failed to apply visual effects:`, error);
@@ -259,44 +218,4 @@ export class WindowThemeManager {
browserWindow.setBackgroundColor(config.backgroundColor);
browserWindow.setHasShadow?.(true);
}
/**
* Apply macOS visual effects.
* - Tahoe+: liquid glass auto-adapts to dark mode; ensure it's applied if not yet.
* - Pre-Tahoe: vibrancy is managed natively by Electron, no runtime action needed.
*/
private applyMacVisualEffects(): void {
if (!this.browserWindow) return;
if (this.useLiquidGlass) {
// Attempt apply if not yet done (e.g. initial load failed, or window recreated)
this.applyLiquidGlass();
}
}
// ==================== Liquid Glass ====================
/**
* Apply liquid glass native view to the window.
* Idempotent — guards against double-application via `liquidGlassViewId`.
*/
applyLiquidGlass(): void {
if (!this.useLiquidGlass || !liquidGlass) return;
if (!this.browserWindow || this.browserWindow.isDestroyed()) return;
if (this.liquidGlassViewId !== undefined) return;
try {
// Ensure traffic light buttons remain visible with transparent window
this.browserWindow.setWindowButtonVisibility(true);
const handle = this.browserWindow.getNativeWindowHandle();
this.liquidGlassViewId = liquidGlass.addView(handle);
liquidGlass.unstable_setVariant(this.liquidGlassViewId, 15);
logger.info(`[${this.identifier}] Liquid glass applied (viewId: ${this.liquidGlassViewId})`);
} catch (error) {
logger.error(`[${this.identifier}] Failed to apply liquid glass:`, error);
}
}
}