style(editor): 完善emit定义

This commit is contained in:
roymondchen 2024-12-18 16:10:07 +08:00
parent 712e317e40
commit 7887a14f6b
2 changed files with 24 additions and 7 deletions

View File

@ -96,9 +96,9 @@
<PropsPanel
:extend-state="extendFormState"
:disabled-show-src="disabledShowSrc"
@mounted="(instance: any) => $emit('props-panel-mounted', instance)"
@form-error="(e: any) => $emit('props-form-error', e)"
@submit-error="(e: any) => $emit('props-submit-error', e)"
@mounted="propsPanelMountedHandler"
@form-error="propsPanelFormErrorHandler"
@submit-error="propsPanelSubmitErrorHandler"
>
<template #props-panel-header>
<slot name="props-panel-header"></slot>
@ -134,6 +134,7 @@ import type { MApp } from '@tmagic/core';
import Framework from './layouts/Framework.vue';
import TMagicNavMenu from './layouts/NavMenu.vue';
import FormPanel from './layouts/props-panel/FormPanel.vue';
import PropsPanel from './layouts/props-panel/PropsPanel.vue';
import Sidebar from './layouts/sidebar/Sidebar.vue';
import Workspace from './layouts/workspace/Workspace.vue';
@ -177,7 +178,7 @@ defineOptions({
});
const emit = defineEmits<{
'props-panel-mounted': [instance: InstanceType<typeof PropsPanel>];
'props-panel-mounted': [instance: InstanceType<typeof FormPanel>];
'update:modelValue': [value: MApp | null];
'props-form-error': [e: any];
'props-submit-error': [e: any];
@ -231,5 +232,17 @@ provide('stageOptions', stageOptions);
provide<EventBus>('eventBus', new EventEmitter());
const propsPanelMountedHandler = (e: InstanceType<typeof FormPanel>) => {
emit('props-panel-mounted', e);
};
const propsPanelSubmitErrorHandler = (e: any) => {
emit('props-submit-error', e);
};
const propsPanelFormErrorHandler = (e: any) => {
emit('props-form-error', e);
};
defineExpose(services);
</script>

View File

@ -76,7 +76,11 @@ defineProps<{
extendState?: (state: FormState) => Record<string, any> | Promise<Record<string, any>>;
}>();
const emit = defineEmits(['mounted', 'submit-error', 'form-error']);
const emit = defineEmits<{
'submit-error': [e: any];
'form-error': [e: any];
mounted: [internalInstance: InstanceType<typeof FormPanel>];
}>();
const services = inject<Services>('services');
@ -126,13 +130,13 @@ const errorHandler = (e: any) => {
emit('form-error', e);
};
const mountedHandler = (e: any) => {
const mountedHandler = (e: InstanceType<typeof FormPanel>) => {
emit('mounted', e);
};
const { showStylePanel, showStylePanelHandler, closeStylePanelHandler } = useStylePanel(services);
const propertyFormPanelRef = useTemplateRef('propertyFormPanel');
const propertyFormPanelRef = useTemplateRef<InstanceType<typeof FormPanel>>('propertyFormPanel');
defineExpose({
getFormState() {
return propertyFormPanelRef.value?.configForm?.formState;