mirror of
https://github.com/ragestudio/relic.git
synced 2025-06-09 10:34:18 +00:00
improve serialize safe
This commit is contained in:
parent
e7cd36a5b3
commit
fd64d24470
@ -5,11 +5,16 @@ const forbidden = [
|
||||
]
|
||||
|
||||
export default (event, data) => {
|
||||
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)) {
|
||||
@ -28,4 +33,7 @@ export default (event, data) => {
|
||||
}
|
||||
|
||||
global.win.webContents.send(event, serializeIpc(data))
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user