mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 13:48:02 +00:00
feat: 实现托盘菜单 (#1538)
* 从 v1 添加托盘相关图标 * feat: ipcRenderer事件 * feat: 托盘菜单实现 * 修复合并后的错误 * fix: 托盘图标的like * 将 tray 相关的 ipc 放入ipcMain.ts * update * update * feat: 设置托盘Tooltip * fix * fix: tray play/pause fade * fix: 暂时将tray like与tooltip的设置移入Player组件中 useUserLikedTracksIDs 会在重新聚焦而不是切换track时触发,导致托盘无法实时更新数据 基于以上一点,在Player组件中有了一个用于设置tray数据的useEffect,故将tray tooltip的设置也放入其中,使tray的数据尽可能简单的和player数据保持一致 * 将部分ipcRenderer调用挪到单独的IpcRendererReact组件 * 移除SetTrayPlayState,复用已有channel * update
This commit is contained in:
parent
b1fd51233a
commit
ffdf66b57e
24 changed files with 392 additions and 19 deletions
|
|
@ -9,9 +9,11 @@ import {
|
|||
} from 'electron'
|
||||
import Store from 'electron-store'
|
||||
import { release } from 'os'
|
||||
import path, { join } from 'path'
|
||||
import { join } from 'path'
|
||||
import log from './log'
|
||||
import { initIpcMain } from './ipcMain'
|
||||
import { createTray, YPMTray } from './tray'
|
||||
import { IpcChannels } from '@/shared/IpcChannels'
|
||||
|
||||
const isWindows = process.platform === 'win32'
|
||||
const isMac = process.platform === 'darwin'
|
||||
|
|
@ -29,6 +31,7 @@ interface TypedElectronStore {
|
|||
|
||||
class Main {
|
||||
win: BrowserWindow | null = null
|
||||
tray: YPMTray | null = null
|
||||
store = new Store<TypedElectronStore>({
|
||||
defaults: {
|
||||
window: {
|
||||
|
|
@ -58,7 +61,8 @@ class Main {
|
|||
this.createWindow()
|
||||
this.handleAppEvents()
|
||||
this.handleWindowEvents()
|
||||
initIpcMain(this.win)
|
||||
this.createTray()
|
||||
initIpcMain(this.win, this.tray)
|
||||
this.initDevTools()
|
||||
})
|
||||
}
|
||||
|
|
@ -83,6 +87,12 @@ class Main {
|
|||
this.win.webContents.openDevTools()
|
||||
}
|
||||
|
||||
createTray() {
|
||||
if (isWindows || isLinux || isDev) {
|
||||
this.tray = createTray(this.win!)
|
||||
}
|
||||
}
|
||||
|
||||
createWindow() {
|
||||
const options: BrowserWindowConstructorOptions = {
|
||||
title: 'YesPlayMusic',
|
||||
|
|
@ -119,11 +129,11 @@ class Main {
|
|||
|
||||
// Window maximize and minimize
|
||||
this.win.on('maximize', () => {
|
||||
this.win && this.win.webContents.send('is-maximized', true)
|
||||
this.win && this.win.webContents.send(IpcChannels.IsMaximized, true)
|
||||
})
|
||||
|
||||
this.win.on('unmaximize', () => {
|
||||
this.win && this.win.webContents.send('is-maximized', false)
|
||||
this.win && this.win.webContents.send(IpcChannels.IsMaximized, false)
|
||||
})
|
||||
|
||||
// Save window position
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue