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