diff --git a/src/main/utils/sendToRender.js b/src/main/utils/sendToRender.js new file mode 100644 index 0000000..8059d87 --- /dev/null +++ b/src/main/utils/sendToRender.js @@ -0,0 +1,23 @@ +import lodash from "lodash" + +export default (event, data) => { + function serializeIpc(data) { + if (!data) { + return undefined + } + + const copy = lodash.cloneDeep(data) + + if (!Array.isArray(copy)) { + Object.keys(copy).forEach((key) => { + if (typeof copy[key] === "function") { + delete copy[key] + } + }) + } + + return copy + } + + global.win.webContents.send(event, serializeIpc(data)) +} \ No newline at end of file