mirror of
https://github.com/qier222/YesPlayMusic.git
synced 2025-02-27 10:10:55 +08:00
41 lines
882 B
TypeScript
41 lines
882 B
TypeScript
import player from '@/web/states/player'
|
|
import { IpcChannels, IpcChannelsReturns, IpcChannelsParams } from '@/shared/IpcChannels'
|
|
import uiStates from './states/uiStates'
|
|
|
|
const on = <T extends keyof IpcChannelsParams>(
|
|
channel: T,
|
|
listener: (event: any, params: IpcChannelsReturns[T]) => void
|
|
) => {
|
|
window.ipcRenderer?.on(channel, listener)
|
|
}
|
|
|
|
export function ipcRenderer() {
|
|
on(IpcChannels.Play, () => {
|
|
player.play(true)
|
|
})
|
|
|
|
on(IpcChannels.Pause, () => {
|
|
player.pause(true)
|
|
})
|
|
|
|
on(IpcChannels.PlayOrPause, () => {
|
|
player.playOrPause()
|
|
})
|
|
|
|
on(IpcChannels.Next, () => {
|
|
player.nextTrack()
|
|
})
|
|
|
|
on(IpcChannels.Previous, () => {
|
|
player.prevTrack()
|
|
})
|
|
|
|
on(IpcChannels.Repeat, (e, mode) => {
|
|
player.repeatMode = mode
|
|
})
|
|
|
|
on(IpcChannels.FullscreenStateChange, (e, isFullscreen) => {
|
|
uiStates.fullscreen = isFullscreen
|
|
})
|
|
}
|