diff --git a/src/main/utils/sendToRender.js b/src/main/utils/sendToRender.js index 73bf3fe..6fc3784 100644 --- a/src/main/utils/sendToRender.js +++ b/src/main/utils/sendToRender.js @@ -5,27 +5,35 @@ const forbidden = [ ] export default (event, data) => { - function serializeIpc(data) { - if (!data) { - return undefined + try { + function serializeIpc(data) { + if (!data) { + return undefined + } + + data = JSON.stringify(data) + + data = JSON.parse(data) + + const copy = lodash.cloneDeep(data) + + if (!Array.isArray(copy)) { + Object.keys(copy).forEach((key) => { + if (forbidden.includes(key)) { + delete copy[key] + } + + if (typeof copy[key] === "function") { + delete copy[key] + } + }) + } + + return copy } - const copy = lodash.cloneDeep(data) - - if (!Array.isArray(copy)) { - Object.keys(copy).forEach((key) => { - if (forbidden.includes(key)) { - delete copy[key] - } - - if (typeof copy[key] === "function") { - delete copy[key] - } - }) - } - - return copy + global.win.webContents.send(event, serializeIpc(data)) + } catch (error) { + console.error(error) } - - global.win.webContents.send(event, serializeIpc(data)) } \ No newline at end of file