mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-06 03:58:04 +08:00
fix: 修复反序列化无法处理es6简写函数的问题
This commit is contained in:
parent
8e28c524b3
commit
8824d636f4
@ -321,6 +321,12 @@ export const JSONParse = (data: string) => {
|
||||
return JSON.parse(data, (k, v) => {
|
||||
if (typeof v === 'string' && v.indexOf && (v.indexOf('function') > -1 || v.indexOf('=>') > -1)) {
|
||||
return eval(`(function(){return ${v}})()`)
|
||||
} else if (typeof v === 'string' && v.indexOf && (v.indexOf('return ') > -1)) {
|
||||
const baseLeftIndex = v.indexOf('(')
|
||||
if (baseLeftIndex > -1) {
|
||||
const newFn = `function ${v.substring(baseLeftIndex)}`
|
||||
return eval(`(function(){return ${newFn}})()`)
|
||||
}
|
||||
}
|
||||
return v
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user