mirror of
https://github.com/ragestudio/relic.git
synced 2025-06-09 10:34:18 +00:00
use sendToRender
This commit is contained in:
parent
2c0533a16f
commit
db3fe91bf0
23
src/main/utils/sendToRender.js
Normal file
23
src/main/utils/sendToRender.js
Normal file
@ -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))
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user