log communication in dev
This commit is contained in:
1 parent
1b015078a6
commit
5ab988dab1
1 file changed
+6
@@ -8,6 +8,9 @@ contextBridge.exposeInMainWorld('mainApi', {
|
||||
send: (channel: string, ...data: any[]): void => {
|
||||
if (mainAvailChannels.includes(channel)) {
|
||||
ipcRenderer.send.apply(null, [channel, ...data])
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.log({ type: 'send', channel, request: data })
|
||||
}
|
||||
} else {
|
||||
throw new Error(`Unknown ipc channel name: ${channel}`)
|
||||
}
|
||||
@@ -36,6 +39,9 @@ contextBridge.exposeInMainWorld('mainApi', {
|
||||
invoke: async (channel: string, ...data: any[]): Promise<any> => {
|
||||
if (mainAvailChannels.includes(channel)) {
|
||||
const result = await ipcRenderer.invoke.apply(null, [channel, ...data])
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.log({ type: 'invoke', channel, request: data, result })
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user