fix(window): 修复 Mica/Acrylic 背景不透明及失焦失效问题

This commit is contained in:
Linkon
2026-01-20 02:28:24 +08:00
parent 32ddc4be46
commit 3c21a05c37
+18 -1
View File
@@ -98,6 +98,8 @@ export class WindowManager extends Service {
show: false, show: false,
autoHideMenuBar: true, autoHideMenuBar: true,
frame: false, frame: false,
transparent: true,
backgroundColor: '#00000000',
icon: this.opts.icon, icon: this.opts.icon,
title: input.title, title: input.title,
webPreferences: { webPreferences: {
@@ -161,6 +163,18 @@ export class WindowManager extends Service {
win.webContents.send('window:maximized-changed', false) win.webContents.send('window:maximized-changed', false)
}) })
win.on('blur', () => {
if (input.key === 'global-sidebar' || input.key === 'main') {
this.applyMicaEffect(win)
}
})
win.on('focus', () => {
if (input.key === 'global-sidebar' || input.key === 'main') {
this.applyMicaEffect(win)
}
})
win.webContents.setWindowOpenHandler((details) => { win.webContents.setWindowOpenHandler((details) => {
shell.openExternal(details.url) shell.openExternal(details.url)
return { action: 'deny' } return { action: 'deny' }
@@ -226,7 +240,10 @@ export class WindowManager extends Service {
} }
} }
public setMicaEffect(win: BrowserWindow, effect: 'mica' | 'tabbed' | 'acrylic' | 'blur' | 'transparent' | 'none' = 'mica') { public setMicaEffect(
win: BrowserWindow,
effect: 'mica' | 'tabbed' | 'acrylic' | 'blur' | 'transparent' | 'none' = 'mica'
) {
if (!micaElectron) return if (!micaElectron) return
const micaWin = win as MicaWindow const micaWin = win as MicaWindow