From 9bec67ebf914a4b7117aa3869d24021751342596 Mon Sep 17 00:00:00 2001 From: hecai Date: Wed, 18 Jun 2025 15:48:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BB=BB=E5=8A=A1=E6=A0=8F?= =?UTF-8?q?=E7=BC=A9=E7=95=A5=E5=9B=BE=E6=8E=A7=E5=88=B6=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit e0ddb7cb4821b5b48ed3ffb99a44c00c8cb4d46e) --- src/main/modules/window.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/modules/window.ts b/src/main/modules/window.ts index 25345df..da482a9 100644 --- a/src/main/modules/window.ts +++ b/src/main/modules/window.ts @@ -1,5 +1,5 @@ import { is } from '@electron-toolkit/utils'; -import { app, BrowserWindow, globalShortcut, ipcMain, screen, session, shell } from 'electron'; +import { app, BrowserWindow, nativeImage, globalShortcut, ipcMain, screen, session, shell } from 'electron'; import Store from 'electron-store'; import { join } from 'path'; import { @@ -189,11 +189,29 @@ export function initializeWindowManager() { } }); + + ipcMain.on('update-play-state', (_, playing: boolean) => { + let isPlaying = playing; + if (mainWindowInstance) { + let mainWindow = mainWindowInstance; + mainWindow.setThumbarButtons([ + { + tooltip: isPlaying ? 'pause' : 'play', + icon: nativeImage + .createFromPath(join(app.getAppPath(), 'resources/icons', isPlaying ? 'pause.png' : 'play.png')), + click() { + mainWindow.webContents.send('global-shortcut', 'togglePlay'); + }, + } + ]); + } + }); + // 监听代理设置变化 store.onDidChange('set.proxyConfig', () => { initializeProxy(); }); - + // 初始化窗口大小和缩放相关的IPC处理程序 initWindowSizeHandlers(mainWindowInstance); // 监听 macOS 下点击 Dock 图标的事件