Skip to content

Commit 17dce0e

Browse files
committed
🐞 fix: 修复透明窗口点击穿透
1 parent e1a22a5 commit 17dce0e

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

electron/main/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ class MainProcess {
7474
// 配置 COOP/COEP/CORP 头,FFmpeg 需要
7575
session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
7676
const responseHeaders = { ...details.responseHeaders };
77+
const url = new URL(details.url);
78+
79+
// 桌面歌词窗口需要透明背景,必须排除严格的安全策略
80+
if (url.searchParams.get("win") === "desktop-lyric") {
81+
callback({ responseHeaders });
82+
return;
83+
}
7784

7885
// 同样可以解决 CORS 限制,但为了避免安全问题,等真有需要的时候再开
7986
// responseHeaders["Access-Control-Allow-Origin"] = ["*"];

electron/main/windows/lyric-window.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ class LyricWindow {
7777
});
7878
if (!this.win) return null;
7979
// 加载地址
80-
this.win.loadURL(lyricWinUrl);
80+
const url = new URL(lyricWinUrl);
81+
url.searchParams.set("win", "desktop-lyric");
82+
this.win.loadURL(url.toString());
8183
// 窗口事件
8284
this.event();
8385
return this.win;

0 commit comments

Comments
 (0)