From ce748a34ad94af4d0af23ea9249cee72f4ffe56c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?=
<1262327911@qq.com>
Date: Tue, 22 Nov 2022 12:42:23 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86=E6=97=A7=E6=95=B0?=
=?UTF-8?q?=E6=8D=AE=E5=9F=BA=E7=A1=80=E4=BA=8B=E4=BB=B6=E6=8A=A5=E9=94=99?=
=?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/hooks/useLifeHandler.hook.ts | 2 ++
.../components/ChartEventAdvancedHandle/index.vue | 6 ++++--
.../components/ChartEventBaseHandle/index.vue | 2 +-
src/views/chart/hooks/useSync.hook.ts | 15 +++++++++++++--
4 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/src/hooks/useLifeHandler.hook.ts b/src/hooks/useLifeHandler.hook.ts
index fde94eef..23ed5e00 100644
--- a/src/hooks/useLifeHandler.hook.ts
+++ b/src/hooks/useLifeHandler.hook.ts
@@ -9,6 +9,8 @@ export const npmPkgs = { echarts }
// 组件事件处理 hook
export const useLifeHandler = (chartConfig: CreateComponentType | CreateComponentGroupType) => {
+ if (!chartConfig.events) return {}
+
// 处理基础事件
const baseEvent: { [key: string]: any } = {}
for (const key in chartConfig.events.baseEvent) {
diff --git a/src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEventAdvancedHandle/index.vue b/src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEventAdvancedHandle/index.vue
index fe89c656..a697a628 100644
--- a/src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEventAdvancedHandle/index.vue
+++ b/src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEventAdvancedHandle/index.vue
@@ -18,7 +18,9 @@
async {{ eventName }} (e, components, echarts, node_modules) {
+
},
@@ -227,7 +229,7 @@ const saveEvents = () => { // 清空事件 targetData.value.events.advancedEvents = { vnodeBeforeMount: undefined, - vnodeMounted: undefined, + vnodeMounted: undefined } } else { targetData.value.events.advancedEvents = { ...advancedEvents.value } diff --git a/src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEventBaseHandle/index.vue b/src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEventBaseHandle/index.vue index 1f9abb99..ec01f60b 100644 --- a/src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEventBaseHandle/index.vue +++ b/src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEventBaseHandle/index.vue @@ -19,7 +19,7 @@ async {{ eventName }} (mouseEvent) {
-
},
diff --git a/src/views/chart/hooks/useSync.hook.ts b/src/views/chart/hooks/useSync.hook.ts index 3d5f1d71..3d551f00 100644 --- a/src/views/chart/hooks/useSync.hook.ts +++ b/src/views/chart/hooks/useSync.hook.ts @@ -3,7 +3,7 @@ import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore import { ChartEditStoreEnum, ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d' import { useChartHistoryStore } from '@/store/modules/chartHistoryStore/chartHistoryStore' import { fetchChartComponent, fetchConfigComponent, createComponent } from '@/packages/index' -import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d' +import { BaseEvent, EventLife, CreateComponentType, CreateComponentGroupType } from '@/packages/index.d' import { PublicGroupConfigClass } from '@/packages/public/publicConfig' import merge from 'lodash/merge' @@ -35,7 +35,18 @@ const componentVersionUpdatePolyfill = (newObject: any, sources: any) => { newObject.events.advancedEvents.vnodeMounted = sources?.events.vnodeMounted } if (hasVnodeBeforeMount || hasVnodeMounted) { - sources.events = undefined + sources.events = { + baseEvent: { + [BaseEvent.ON_CLICK]: undefined, + [BaseEvent.ON_DBL_CLICK]: undefined, + [BaseEvent.ON_MOUSE_ENTER]: undefined, + [BaseEvent.ON_MOUSE_LEAVE]: undefined + }, + advancedEvents: { + [EventLife.VNODE_MOUNTED]: undefined, + [EventLife.VNODE_BEFORE_MOUNT]: undefined + } + } } return newObject }