mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 16:22:57 +08:00
fix: 排除反序列化函数的问题,规范事件类型代码
This commit is contained in:
parent
c11ef13c04
commit
9182e97734
31
src/enums/eventEnum.ts
Normal file
31
src/enums/eventEnum.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// 基础事件类型(vue不加 on)
|
||||||
|
export enum BaseEvent {
|
||||||
|
// 点击
|
||||||
|
ON_CLICK = 'click',
|
||||||
|
// 双击
|
||||||
|
ON_DBL_CLICK = 'dblclick',
|
||||||
|
// 移入
|
||||||
|
ON_MOUSE_ENTER = 'mouseenter',
|
||||||
|
// 移出
|
||||||
|
ON_MOUSE_LEAVE = 'mouseleave',
|
||||||
|
}
|
||||||
|
|
||||||
|
// vue3 生命周期事件
|
||||||
|
export enum EventLife {
|
||||||
|
// 渲染之后
|
||||||
|
VNODE_MOUNTED = 'vnodeMounted',
|
||||||
|
// 渲染之前
|
||||||
|
VNODE_BEFORE_MOUNT = 'vnodeBeforeMount',
|
||||||
|
}
|
||||||
|
|
||||||
|
// 内置字符串函数对象列表
|
||||||
|
export const excludeParseEventKeyList = [
|
||||||
|
EventLife.VNODE_BEFORE_MOUNT,
|
||||||
|
EventLife.VNODE_MOUNTED,
|
||||||
|
BaseEvent.ON_CLICK,
|
||||||
|
BaseEvent.ON_DBL_CLICK,
|
||||||
|
BaseEvent.ON_MOUSE_ENTER,
|
||||||
|
BaseEvent.ON_MOUSE_LEAVE,
|
||||||
|
//过滤器
|
||||||
|
'filter'
|
||||||
|
]
|
@ -1,4 +1,5 @@
|
|||||||
import { CreateComponentType, CreateComponentGroupType, EventLife, BaseEvent } from '@/packages/index.d'
|
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
|
||||||
|
import { EventLife } from '@/enums/eventEnum'
|
||||||
import * as echarts from 'echarts'
|
import * as echarts from 'echarts'
|
||||||
|
|
||||||
// 所有图表组件集合对象
|
// 所有图表组件集合对象
|
||||||
|
21
src/packages/index.d.ts
vendored
21
src/packages/index.d.ts
vendored
@ -1,3 +1,4 @@
|
|||||||
|
import { BaseEvent, EventLife } from '@/enums/eventEnum'
|
||||||
import type { GlobalThemeJsonType } from '@/settings/chartThemes/index'
|
import type { GlobalThemeJsonType } from '@/settings/chartThemes/index'
|
||||||
import type { RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
import type { RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||||
|
|
||||||
@ -90,26 +91,6 @@ export const BlendModeEnumList = [
|
|||||||
{ label: '亮度', value: 'luminosity' }
|
{ label: '亮度', value: 'luminosity' }
|
||||||
]
|
]
|
||||||
|
|
||||||
// 基础事件类型(vue不加 on)
|
|
||||||
export enum BaseEvent {
|
|
||||||
// 点击
|
|
||||||
ON_CLICK = 'click',
|
|
||||||
// 双击
|
|
||||||
ON_DBL_CLICK = 'dblclick',
|
|
||||||
// 移入
|
|
||||||
ON_MOUSE_ENTER = 'mouseenter',
|
|
||||||
// 移出
|
|
||||||
ON_MOUSE_LEAVE = 'mouseleave',
|
|
||||||
}
|
|
||||||
|
|
||||||
// vue3 生命周期事件
|
|
||||||
export enum EventLife {
|
|
||||||
// 渲染之后
|
|
||||||
VNODE_MOUNTED = 'vnodeMounted',
|
|
||||||
// 渲染之前
|
|
||||||
VNODE_BEFORE_MOUNT = 'vnodeBeforeMount',
|
|
||||||
}
|
|
||||||
|
|
||||||
// 组件实例类
|
// 组件实例类
|
||||||
export interface PublicConfigType {
|
export interface PublicConfigType {
|
||||||
id: string
|
id: string
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { getUUID } from '@/utils'
|
import { getUUID } from '@/utils'
|
||||||
import { RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
import { RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||||
import { groupTitle } from '@/settings/designSetting'
|
import { groupTitle } from '@/settings/designSetting'
|
||||||
|
import { BaseEvent, EventLife } from '@/enums/eventEnum'
|
||||||
import {
|
import {
|
||||||
RequestHttpEnum,
|
RequestHttpEnum,
|
||||||
RequestDataTypeEnum,
|
RequestDataTypeEnum,
|
||||||
@ -9,8 +10,6 @@ import {
|
|||||||
RequestBodyEnum
|
RequestBodyEnum
|
||||||
} from '@/enums/httpEnum'
|
} from '@/enums/httpEnum'
|
||||||
import {
|
import {
|
||||||
BaseEvent,
|
|
||||||
EventLife,
|
|
||||||
ChartFrameEnum,
|
ChartFrameEnum,
|
||||||
PublicConfigType,
|
PublicConfigType,
|
||||||
CreateComponentType,
|
CreateComponentType,
|
||||||
|
@ -57,7 +57,7 @@ export const setSessionStorage = <T>(k: string, v: T) => {
|
|||||||
export const getSessionStorage: (k: string) => any = (k: string) => {
|
export const getSessionStorage: (k: string) => any = (k: string) => {
|
||||||
const item = window.sessionStorage.getItem(k)
|
const item = window.sessionStorage.getItem(k)
|
||||||
try {
|
try {
|
||||||
return item ? JSON.parse(item) : item
|
return item ? JSONParse(item) : item
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import cloneDeep from 'lodash/cloneDeep'
|
|||||||
import { WinKeyboard } from '@/enums/editPageEnum'
|
import { WinKeyboard } from '@/enums/editPageEnum'
|
||||||
import { RequestHttpIntervalEnum, RequestParamsObjType } from '@/enums/httpEnum'
|
import { RequestHttpIntervalEnum, RequestParamsObjType } from '@/enums/httpEnum'
|
||||||
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
|
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) => {
|
export const JSONParse = (data: string) => {
|
||||||
return JSON.parse(data, (k, v) => {
|
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)) {
|
if (typeof v === 'string' && v.indexOf && (v.indexOf('function') > -1 || v.indexOf('=>') > -1)) {
|
||||||
return eval(`(function(){return ${v}})()`)
|
return eval(`(function(){return ${v}})()`)
|
||||||
} else if (typeof v === 'string' && v.indexOf && (v.indexOf('return ') > -1)) {
|
} else if (typeof v === 'string' && v.indexOf && (v.indexOf('return ') > -1)) {
|
||||||
|
@ -164,7 +164,8 @@ import { useTargetData } from '../../../hooks/useTargetData.hook'
|
|||||||
import { templateList } from './importTemplate'
|
import { templateList } from './importTemplate'
|
||||||
import { npmPkgs } from '@/hooks'
|
import { npmPkgs } from '@/hooks'
|
||||||
import { icon } from '@/plugins'
|
import { icon } from '@/plugins'
|
||||||
import { CreateComponentType, EventLife } from '@/packages/index.d'
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
|
import { EventLife } from '@/enums/eventEnum'
|
||||||
|
|
||||||
const { targetData, chartEditStore } = useTargetData()
|
const { targetData, chartEditStore } = useTargetData()
|
||||||
const { DocumentTextIcon, ChevronDownIcon, PencilIcon } = icon.ionicons5
|
const { DocumentTextIcon, ChevronDownIcon, PencilIcon } = icon.ionicons5
|
||||||
|
@ -127,7 +127,7 @@
|
|||||||
import { ref, computed, watch, toRefs, toRaw } from 'vue'
|
import { ref, computed, watch, toRefs, toRaw } from 'vue'
|
||||||
import { MonacoEditor } from '@/components/Pages/MonacoEditor'
|
import { MonacoEditor } from '@/components/Pages/MonacoEditor'
|
||||||
import { useTargetData } from '../../../hooks/useTargetData.hook'
|
import { useTargetData } from '../../../hooks/useTargetData.hook'
|
||||||
import { CreateComponentType, BaseEvent } from '@/packages/index.d'
|
import { BaseEvent } from '@/enums/eventEnum'
|
||||||
import { icon } from '@/plugins'
|
import { icon } from '@/plugins'
|
||||||
|
|
||||||
const { targetData, chartEditStore } = useTargetData()
|
const { targetData, chartEditStore } = useTargetData()
|
||||||
|
@ -5,7 +5,8 @@ import { useChartHistoryStore } from '@/store/modules/chartHistoryStore/chartHis
|
|||||||
import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
|
import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
|
||||||
import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
|
import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
|
||||||
import { fetchChartComponent, fetchConfigComponent, createComponent } from '@/packages/index'
|
import { fetchChartComponent, fetchConfigComponent, createComponent } from '@/packages/index'
|
||||||
import { BaseEvent, EventLife, CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
|
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
|
||||||
|
import { BaseEvent, EventLife } from '@/enums/eventEnum'
|
||||||
import { PublicGroupConfigClass } from '@/packages/public/publicConfig'
|
import { PublicGroupConfigClass } from '@/packages/public/publicConfig'
|
||||||
import merge from 'lodash/merge'
|
import merge from 'lodash/merge'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user