refactor: clean plugin-core index

This commit is contained in:
sealday 2024-03-19 12:01:14 +08:00
parent f4be99e802
commit d3c3322fd4

View File

@ -105,6 +105,44 @@ export class PluginCoreClient extends Plugin {
}); });
this.schemaSettingsManager.add(groupBlockSettings); this.schemaSettingsManager.add(groupBlockSettings);
this.schemaSettingsManager.add(customComponentDispatcherSettings); this.schemaSettingsManager.add(customComponentDispatcherSettings);
this.schemaSettingsManager.addItem('FilterFormItemSettings', 'formulatitleField', {
Component: EditFormulaTitleField,
useVisible: useFormulaTitleVisible,
});
this.schemaSettingsManager.addItem('FormItemSettings', 'hera-divider', {
type: 'divider',
useVisible() {
const v1 = useFormulaTitleVisible();
const v2 = usePaginationVisible();
return v1 || v2;
},
});
this.schemaSettingsManager.addItem('FormItemSettings', 'formulatitleField', {
Component: EditFormulaTitleField,
useVisible: useFormulaTitleVisible,
});
this.schemaSettingsManager.addItem('FormItemSettings', 'isTablePageSize', {
Component: IsTablePageSize,
useVisible: usePaginationVisible,
});
this.schemaSettingsManager.addItem('ActionSettings', 'Customize.setFilterScope', {
Component: SetFilterScope,
useVisible: useSetFilterScopeVisible,
useComponentProps() {
const collection = useCollection();
return {
collectionName: collection.name,
};
},
});
const SchemaSettingOptionItems = this.schemaSettingsManager
.get('ActionSettings')
.items.filter((item) => item.name === 'Customize')[0].children;
SchemaSettingOptionItems.forEach((item) => {
if (item.name === 'afterSuccess') {
(item as SchemaSettingOptions).Component = AfterSuccess;
}
});
} }
async registerActions() { async registerActions() {
@ -127,57 +165,57 @@ export class PluginCoreClient extends Plugin {
async registerScopesAndComponents() { async registerScopesAndComponents() {
this.app.addScopes({ this.app.addScopes({
useOutboundActionProps,
useCustomizeUpdateActionProps,
useCreateActionProps, useCreateActionProps,
useFilterFormCustomProps, useCustomizeUpdateActionProps,
useFilterBlockActionProps, useFilterBlockActionProps,
usePDFViewerPrintActionProps, useFilterFormCustomProps,
useGetCustomAssociatedComponents, useGetCustomAssociatedComponents,
useGetCustomComponents, useGetCustomComponents,
useOutboundActionProps,
usePDFViewerPrintActionProps,
}); });
this.app.addComponents({ this.app.addComponents({
AssociatedField,
Expression,
CustomField,
CustomAssociatedField,
CalcResult,
PDFViewerPrintActionInitializer,
PDFViewerProvider,
GroupBlock,
CustomComponentStub,
CustomComponentDispatcher,
GroupBlockInitializer,
GroupBlockToolbar,
GroupBlockProvider,
DatePicker,
RemoteSelect,
SignatureInput,
OutboundButton,
OutboundLinkActionInitializer,
PDFViewerBlockInitializer,
PDFViwer: InternalPDFViewer,
AdminLayout, AdminLayout,
ExtendedCalendarBlockInitializer: CalendarBlockInitializer, AfterSuccess,
SettingBlock: SettingBlockInitializer, AssociatedField,
AutoComplete,
CalcResult,
CreateSubmitActionInitializer, CreateSubmitActionInitializer,
PageLayout, CustomAssociatedField,
FilterAssociatedFields, CustomComponentDispatcher,
FilterFormItemCustom, CustomComponentStub,
FilterFormItem, CustomField,
FilterItemCustomDesigner, DatePicker,
Select,
EditTitle, EditTitle,
EditTitleField, EditTitleField,
AfterSuccess, Expression,
ExtendedCalendarBlockInitializer: CalendarBlockInitializer,
FilterAssociatedFields,
FilterFormItem,
FilterFormItemCustom,
FilterItemCustomDesigner,
GroupBlock,
GroupBlockConfigure, GroupBlockConfigure,
AutoComplete, GroupBlockInitializer,
GroupBlockProvider,
GroupBlockToolbar,
Menu: { Menu: {
...Menu, ...Menu,
// @ts-ignore // @ts-ignore
Designer: MenuDesigner, Designer: MenuDesigner,
}, },
OutboundButton,
OutboundLinkActionInitializer,
PDFViewerBlockInitializer,
PDFViewerPrintActionInitializer,
PDFViewerProvider,
PDFViwer: InternalPDFViewer,
PageLayout,
RemoteSelect,
Select,
SettingBlock: SettingBlockInitializer,
SignatureInput,
}); });
} }
@ -281,19 +319,13 @@ export class PluginCoreClient extends Plugin {
addCustomComponent.name, addCustomComponent.name,
addCustomComponent, addCustomComponent,
); );
} const previewBlockItem = {
title: tval('preview block'),
async afterAdd() {} name: 'previewBlock',
async beforeLoad() {} type: 'itemGroup',
async afterLoad() { children: [],
// log for debug };
if (process.env.NODE_ENV !== 'production') { this.app.schemaInitializerManager.get('RecordBlockInitializers').add(previewBlockItem.name, previewBlockItem);
console.info('current components', this.app.components);
console.info('current schemaSettings', this.app.schemaSettingsManager.getAll());
console.info('current schemaInitializer', this.app.schemaInitializerManager.getAll());
console.info('current providers', this.app.providers);
}
await this.registerSchemaInitializer();
} }
async registerInterfaces() { async registerInterfaces() {
@ -306,6 +338,17 @@ export class PluginCoreClient extends Plugin {
]); ]);
} }
async afterLoad() {
// log for debug
if (process.env.NODE_ENV !== 'production') {
console.info('current components', this.app.components);
console.info('current schemaSettings', this.app.schemaSettingsManager.getAll());
console.info('current schemaInitializer', this.app.schemaInitializerManager.getAll());
console.info('current providers', this.app.providers);
}
await this.registerSchemaInitializer();
}
async load() { async load() {
this.locale = new Locale(this.app); this.locale = new Locale(this.app);
await this.registerTricks(); await this.registerTricks();
@ -314,51 +357,6 @@ export class PluginCoreClient extends Plugin {
await this.registerActions(); await this.registerActions();
await this.registerRouters(); await this.registerRouters();
await this.registerInterfaces(); await this.registerInterfaces();
this.schemaSettingsManager.addItem('FilterFormItemSettings', 'formulatitleField', {
Component: EditFormulaTitleField,
useVisible: useFormulaTitleVisible,
});
this.schemaSettingsManager.addItem('FormItemSettings', 'hera-divider', {
type: 'divider',
useVisible() {
const v1 = useFormulaTitleVisible();
const v2 = usePaginationVisible();
return v1 || v2;
},
});
this.schemaSettingsManager.addItem('FormItemSettings', 'formulatitleField', {
Component: EditFormulaTitleField,
useVisible: useFormulaTitleVisible,
});
this.schemaSettingsManager.addItem('FormItemSettings', 'isTablePageSize', {
Component: IsTablePageSize,
useVisible: usePaginationVisible,
});
this.schemaSettingsManager.addItem('ActionSettings', 'Customize.setFilterScope', {
Component: SetFilterScope,
useVisible: useSetFilterScopeVisible,
useComponentProps() {
const collection = useCollection();
return {
collectionName: collection.name,
};
},
});
const SchemaSettingOptionItems = this.schemaSettingsManager
.get('ActionSettings')
.items.filter((item) => item.name === 'Customize')[0].children;
SchemaSettingOptionItems.forEach((item) => {
if (item.name === 'afterSuccess') {
(item as SchemaSettingOptions).Component = AfterSuccess;
}
});
const previewBlockItem = {
title: tval('preview block'),
name: 'previewBlock',
type: 'itemGroup',
children: [],
};
this.app.schemaInitializerManager.get('RecordBlockInitializers').add(previewBlockItem.name, previewBlockItem);
// listen to connected events. // listen to connected events.
autorun(() => { autorun(() => {