Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: events meta app support custom common events and components #586

Merged
merged 10 commits into from
Jun 26, 2024
13 changes: 12 additions & 1 deletion packages/settings/events/meta.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { commonEvents } from './src/commonjs/events.js'
import BindEventsDialogBodyLeft from './src/components/BindEventsDialogBodyLeft.vue'
import BindEventsDialogBodyRight from './src/components/BindEventsDialogBodyRight.vue'

export default {
id: 'engine.setting.event',
title: '高级',
type: 'setting',
align: 'left',
name: 'event',
icon: ''
icon: '',
options: {
commonEvents
},
components: {
BindEventsDialogBodyLeft,
BindEventsDialogBodyRight
}
}
2 changes: 1 addition & 1 deletion packages/settings/events/src/components/AdvanceConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
import { ref, computed, reactive, watch } from 'vue'
import { MetaInput } from '@opentiny/tiny-engine-common'
import { CodeConfigurator, SwitchConfigurator, VariableConfigurator } from '@opentiny/tiny-engine-configurator'
import { useProperties, useCanvas } from '@opentiny/tiny-engine-controller'
import { useProperties, useCanvas } from '@opentiny/tiny-engine-entry'
import { PROP_DATA_TYPE } from '@opentiny/tiny-engine-controller/utils'
import { string2Obj } from '@opentiny/tiny-engine-controller/adapter'
import { constants } from '@opentiny/tiny-engine-utils'
Expand Down
8 changes: 5 additions & 3 deletions packages/settings/events/src/components/BindEvents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@
<script>
import { computed, reactive, watchEffect } from 'vue'
import { Popover, Button } from '@opentiny/vue'
import { useCanvas, useModal, useLayout, useBlock, useResource } from '@opentiny/tiny-engine-controller'
import { useModal } from '@opentiny/tiny-engine-controller'
import { getMergeMeta, useCanvas, useLayout, useBlock, useResource } from '@opentiny/tiny-engine-entry'
import { BlockLinkEvent, SvgButton } from '@opentiny/tiny-engine-common'
import { iconHelpQuery, iconChevronDown } from '@opentiny/vue-icon'
import BindEventsDialog, { open as openDialog } from './BindEventsDialog.vue'
import { commonEvents } from '../commonjs/events.js'
import AddEventsDialog from './AddEventsDialog.vue'

export default {
Expand All @@ -115,6 +115,8 @@ export default {

const { highlightMethod } = getPluginApi(PLUGIN_NAME.PageController)

const { commonEvents = {} } = getMergeMeta('engine.setting.event').options

gene9831 marked this conversation as resolved.
Show resolved Hide resolved
const state = reactive({
eventName: '', // 事件名称
eventBinding: null, // 事件绑定的处理方法对象
Expand All @@ -131,7 +133,7 @@ export default {
const componentName = pageState?.currentSchema?.componentName
const componentSchema = getMaterial(componentName)
state.componentEvent = componentSchema?.content?.schema?.events || componentSchema?.schema?.events || {}
Object.assign(state.componentEvents, state.componentEvent)
state.componentEvents = { ...commonEvents, ...state.componentEvent }
const props = pageState?.currentSchema?.props || {}
const keys = Object.keys(props)
state.bindActions = {}
Expand Down
Loading