Skip to content

Commit 9bec67e

Browse files
committed
添加任务栏缩略图控制按钮
(cherry picked from commit e0ddb7c)
1 parent 386c9c7 commit 9bec67e

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/main/modules/window.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { is } from '@electron-toolkit/utils';
2-
import { app, BrowserWindow, globalShortcut, ipcMain, screen, session, shell } from 'electron';
2+
import { app, BrowserWindow, nativeImage, globalShortcut, ipcMain, screen, session, shell } from 'electron';
33
import Store from 'electron-store';
44
import { join } from 'path';
55
import {
@@ -189,11 +189,29 @@ export function initializeWindowManager() {
189189
}
190190
});
191191

192+
193+
ipcMain.on('update-play-state', (_, playing: boolean) => {
194+
let isPlaying = playing;
195+
if (mainWindowInstance) {
196+
let mainWindow = mainWindowInstance;
197+
mainWindow.setThumbarButtons([
198+
{
199+
tooltip: isPlaying ? 'pause' : 'play',
200+
icon: nativeImage
201+
.createFromPath(join(app.getAppPath(), 'resources/icons', isPlaying ? 'pause.png' : 'play.png')),
202+
click() {
203+
mainWindow.webContents.send('global-shortcut', 'togglePlay');
204+
},
205+
}
206+
]);
207+
}
208+
});
209+
192210
// 监听代理设置变化
193211
store.onDidChange('set.proxyConfig', () => {
194212
initializeProxy();
195213
});
196-
214+
197215
// 初始化窗口大小和缩放相关的IPC处理程序
198216
initWindowSizeHandlers(mainWindowInstance);
199217
// 监听 macOS 下点击 Dock 图标的事件

0 commit comments

Comments
 (0)