mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-28 02:47:22 +08:00
启动默认显示缩略图控制按钮。
(cherry picked from commit 1f438e391ab7bb37e38a31ec571724d33f35310b)
This commit is contained in:
+39
-14
@@ -20,7 +20,7 @@ const store = new Store();
|
|||||||
|
|
||||||
// 保存主窗口引用,以便在 activate 事件中使用
|
// 保存主窗口引用,以便在 activate 事件中使用
|
||||||
let mainWindowInstance: BrowserWindow | null = null;
|
let mainWindowInstance: BrowserWindow | null = null;
|
||||||
|
let isPlaying = false;
|
||||||
// 保存迷你模式前的窗口状态
|
// 保存迷你模式前的窗口状态
|
||||||
let preMiniModeState: WindowState = {
|
let preMiniModeState: WindowState = {
|
||||||
width: DEFAULT_MAIN_WIDTH,
|
width: DEFAULT_MAIN_WIDTH,
|
||||||
@@ -56,6 +56,38 @@ function initializeProxy() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setThumbarButtons(window: BrowserWindow) {
|
||||||
|
window.setThumbarButtons([
|
||||||
|
{
|
||||||
|
tooltip: 'prev',
|
||||||
|
icon: nativeImage
|
||||||
|
.createFromPath(join(app.getAppPath(), 'resources/icons', 'prev.png')),
|
||||||
|
click() {
|
||||||
|
window.webContents.send('global-shortcut', 'prevPlay');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
tooltip: isPlaying ? 'pause' : 'play',
|
||||||
|
icon: nativeImage
|
||||||
|
.createFromPath(join(app.getAppPath(), 'resources/icons', isPlaying ? 'pause.png' : 'play.png')),
|
||||||
|
click() {
|
||||||
|
window.webContents.send('global-shortcut', 'togglePlay');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
tooltip: 'next',
|
||||||
|
icon: nativeImage
|
||||||
|
.createFromPath(join(app.getAppPath(), 'resources/icons', 'next.png')),
|
||||||
|
click() {
|
||||||
|
window.webContents.send('global-shortcut', 'nextPlay');
|
||||||
|
},
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化窗口管理相关的IPC监听
|
* 初始化窗口管理相关的IPC监听
|
||||||
*/
|
*/
|
||||||
@@ -191,19 +223,9 @@ export function initializeWindowManager() {
|
|||||||
|
|
||||||
|
|
||||||
ipcMain.on('update-play-state', (_, playing: boolean) => {
|
ipcMain.on('update-play-state', (_, playing: boolean) => {
|
||||||
let isPlaying = playing;
|
isPlaying = playing;
|
||||||
if (mainWindowInstance) {
|
if (mainWindowInstance) {
|
||||||
let mainWindow = mainWindowInstance;
|
setThumbarButtons(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');
|
|
||||||
},
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -268,6 +290,10 @@ export function createMainWindow(icon: Electron.NativeImage): BrowserWindow {
|
|||||||
preMiniModeState = { ...savedState };
|
preMiniModeState = { ...savedState };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mainWindow.on('show', () => {
|
||||||
|
setThumbarButtons(mainWindow);
|
||||||
|
});
|
||||||
|
|
||||||
mainWindow.on('ready-to-show', () => {
|
mainWindow.on('ready-to-show', () => {
|
||||||
const [width, height] = mainWindow.getSize();
|
const [width, height] = mainWindow.getSize();
|
||||||
console.log(`窗口显示前的大小: ${width}x${height}`);
|
console.log(`窗口显示前的大小: ${width}x${height}`);
|
||||||
@@ -279,7 +305,6 @@ export function createMainWindow(icon: Electron.NativeImage): BrowserWindow {
|
|||||||
|
|
||||||
// 显示窗口
|
// 显示窗口
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
|
|
||||||
// 应用页面内容缩放
|
// 应用页面内容缩放
|
||||||
applyContentZoom(mainWindow);
|
applyContentZoom(mainWindow);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user