mirror of
https://github.com/qier222/YesPlayMusic.git
synced 2024-12-02 05:23:39 +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
|