fix: 排除反序列化函数的问题,规范事件类型代码

This commit is contained in:
奔跑的面条
2023-01-17 15:31:16 +08:00
parent c11ef13c04
commit 9182e97734
9 changed files with 43 additions and 27 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ export const setSessionStorage = <T>(k: string, v: T) => {
export const getSessionStorage: (k: string) => any = (k: string) => {
const item = window.sessionStorage.getItem(k)
try {
return item ? JSON.parse(item) : item
return item ? JSONParse(item) : item
} catch (err) {
return item
}
+2
View File
@@ -10,6 +10,7 @@ import cloneDeep from 'lodash/cloneDeep'
import { WinKeyboard } from '@/enums/editPageEnum'
import { RequestHttpIntervalEnum, RequestParamsObjType } from '@/enums/httpEnum'
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
import { excludeParseEventKeyList } from '@/enums/eventEnum'
/**
* * 判断是否是开发环境
@@ -319,6 +320,7 @@ export const JSONStringify = <T>(data: T) => {
*/
export const JSONParse = (data: string) => {
return JSON.parse(data, (k, v) => {
if (excludeParseEventKeyList.includes(k)) return 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)) {