Skip to content

Commit 5417f1a

Browse files
committed
🐞 fix: 修复应用退出不及时
1 parent 62a0974 commit 5417f1a

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

electron/main/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { trySendCustomProtocol } from "./utils/protocol";
1515
import { initSingleLock } from "./utils/single-lock";
1616
import loadWindow from "./windows/load-window";
1717
import mainWindow from "./windows/main-window";
18+
import taskbarLyricWindow from "./windows/taskbar-lyric-window";
1819

1920
// 屏蔽报错
2021
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = "true";
@@ -142,6 +143,8 @@ class MainProcess {
142143
unregisterShortcuts();
143144
// 清理媒体集成资源
144145
shutdownMedia();
146+
// 销毁任务栏歌词窗口
147+
taskbarLyricWindow.destroy();
145148
// 停止 MPV 服务
146149
const mpvService = MpvService.getInstance();
147150
try {

electron/main/windows/taskbar-lyric-window.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class TaskbarLyricWindow {
174174
}
175175

176176
this.win.on("closed", () => {
177-
this.disposeNativeResources();
177+
this.destroy();
178178
this.win = null;
179179
});
180180

@@ -259,7 +259,7 @@ class TaskbarLyricWindow {
259259
shouldCenter = false;
260260
} else if (layout.systemType === "win11" && layout.win11) {
261261
const { startButton, widgets, content, tray, isCentered } = layout.win11;
262-
262+
263263
let effectiveRightAnchor = tray.x;
264264
const contentRightEdge = content.x + content.width;
265265
if (widgets.width > 0 && widgets.x > contentRightEdge) {
@@ -409,7 +409,7 @@ class TaskbarLyricWindow {
409409
}, interval);
410410
}
411411

412-
private disposeNativeResources() {
412+
public destroy() {
413413
if (this.isNativeDisposed) return;
414414
this.debouncedUpdateLayout.cancel();
415415
this.debouncedRegistryUpdate.cancel();
@@ -457,7 +457,7 @@ class TaskbarLyricWindow {
457457
}
458458

459459
close(animate: boolean = true) {
460-
this.disposeNativeResources();
460+
this.destroy();
461461
if (this.animationTimer) {
462462
clearInterval(this.animationTimer);
463463
this.animationTimer = null;

0 commit comments

Comments
 (0)