mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
refactor: improved Proxy handlement on ipc
This commit is contained in:
21
src/renderer/libs/unproxify.js
Normal file
21
src/renderer/libs/unproxify.js
Normal file
@ -0,0 +1,21 @@
|
||||
import { toRaw } from 'vue';
|
||||
|
||||
/**
|
||||
* @param {*} val
|
||||
* @param {Boolean} json converts the value in JSON object (default true)
|
||||
*/
|
||||
export function unproxify (val, json = true) {
|
||||
if (json)// JSON conversion
|
||||
return JSON.parse(JSON.stringify(val));
|
||||
else if (Array.isArray(val))// If array
|
||||
return toRaw(val);
|
||||
else if (typeof val === 'object') { // If object
|
||||
const result = {};
|
||||
for (const key in val)
|
||||
result[key] = toRaw(val[key]);
|
||||
|
||||
return result;
|
||||
}
|
||||
else
|
||||
return toRaw(val);
|
||||
}
|
Reference in New Issue
Block a user