mirror of
https://gitee.com/dromara/go-view.git
synced 2024-12-02 19:59:04 +08:00
fix: 处理旧数据基础事件报错的问题
This commit is contained in:
parent
be014225c1
commit
5ea963fb93
@ -9,6 +9,8 @@ export const npmPkgs = { echarts }
|
|||||||
|
|
||||||
// 组件事件处理 hook
|
// 组件事件处理 hook
|
||||||
export const useLifeHandler = (chartConfig: CreateComponentType | CreateComponentGroupType) => {
|
export const useLifeHandler = (chartConfig: CreateComponentType | CreateComponentGroupType) => {
|
||||||
|
if (!chartConfig.events) return {}
|
||||||
|
|
||||||
// 处理基础事件
|
// 处理基础事件
|
||||||
const baseEvent: { [key: string]: any } = {}
|
const baseEvent: { [key: string]: any } = {}
|
||||||
for (const key in chartConfig.events.baseEvent) {
|
for (const key in chartConfig.events.baseEvent) {
|
||||||
|
@ -18,7 +18,9 @@
|
|||||||
<br />
|
<br />
|
||||||
<span class="func-keyword">async {{ eventName }}</span> (e, components, echarts, node_modules) {
|
<span class="func-keyword">async {{ eventName }}</span> (e, components, echarts, node_modules) {
|
||||||
</p>
|
</p>
|
||||||
<p class="go-ml-4"><n-code :code="(targetData.events.advancedEvents || {})[eventName]" language="typescript"></n-code></p>
|
<p class="go-ml-4">
|
||||||
|
<n-code :code="(targetData.events.advancedEvents || {})[eventName] || ''" language="typescript"></n-code>
|
||||||
|
</p>
|
||||||
<p>}<span>,</span></p>
|
<p>}<span>,</span></p>
|
||||||
</div>
|
</div>
|
||||||
</n-card>
|
</n-card>
|
||||||
@ -227,7 +229,7 @@ const saveEvents = () => {
|
|||||||
// 清空事件
|
// 清空事件
|
||||||
targetData.value.events.advancedEvents = {
|
targetData.value.events.advancedEvents = {
|
||||||
vnodeBeforeMount: undefined,
|
vnodeBeforeMount: undefined,
|
||||||
vnodeMounted: undefined,
|
vnodeMounted: undefined
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
targetData.value.events.advancedEvents = { ...advancedEvents.value }
|
targetData.value.events.advancedEvents = { ...advancedEvents.value }
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<span class="func-keyword">async {{ eventName }}</span> (mouseEvent) {
|
<span class="func-keyword">async {{ eventName }}</span> (mouseEvent) {
|
||||||
</p>
|
</p>
|
||||||
<p class="go-ml-4">
|
<p class="go-ml-4">
|
||||||
<n-code :code="(targetData.events.baseEvent || {})[eventName]" language="typescript"></n-code>
|
<n-code :code="(targetData.events.baseEvent || {})[eventName] || ''" language="typescript"></n-code>
|
||||||
</p>
|
</p>
|
||||||
<p>}<span>,</span></p>
|
<p>}<span>,</span></p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -3,7 +3,7 @@ import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore
|
|||||||
import { ChartEditStoreEnum, ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d'
|
import { ChartEditStoreEnum, ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||||
import { useChartHistoryStore } from '@/store/modules/chartHistoryStore/chartHistoryStore'
|
import { useChartHistoryStore } from '@/store/modules/chartHistoryStore/chartHistoryStore'
|
||||||
import { fetchChartComponent, fetchConfigComponent, createComponent } from '@/packages/index'
|
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 { PublicGroupConfigClass } from '@/packages/public/publicConfig'
|
||||||
import merge from 'lodash/merge'
|
import merge from 'lodash/merge'
|
||||||
|
|
||||||
@ -35,7 +35,18 @@ const componentVersionUpdatePolyfill = (newObject: any, sources: any) => {
|
|||||||
newObject.events.advancedEvents.vnodeMounted = sources?.events.vnodeMounted
|
newObject.events.advancedEvents.vnodeMounted = sources?.events.vnodeMounted
|
||||||
}
|
}
|
||||||
if (hasVnodeBeforeMount || hasVnodeMounted) {
|
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
|
return newObject
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user