mirror of
https://github.com/qier222/YesPlayMusic.git
synced 2024-12-11 11:43:39 +08:00
14 lines
353 B
TypeScript
14 lines
353 B
TypeScript
import { IpcChannels, IpcChannelsReturns } from '@/shared/IpcChannels'
|
|
import { useEffect } from 'react'
|
|
|
|
const useIpcRenderer = <T extends IpcChannels>(
|
|
channel: T,
|
|
listener: (event: any, value: IpcChannelsReturns[T]) => void
|
|
) => {
|
|
useEffect(() => {
|
|
return window.ipcRenderer?.on(channel, listener)
|
|
}, [])
|
|
}
|
|
|
|
export default useIpcRenderer
|