1
0
mirror of synced 2026-04-05 07:48:35 +08:00

fix(ui): 页面组件无法支持event配置

This commit is contained in:
roymondchen
2022-06-06 15:24:59 +08:00
committed by jia000
parent 5d159ad9d8
commit cdabe36b93
9 changed files with 96 additions and 17 deletions

View File

@@ -18,7 +18,7 @@
import React from 'react';
import { MPage } from '@tmagic/schema';
import { MComponent, MContainer, MPage } from '@tmagic/schema';
import useApp from '../useApp';
@@ -27,15 +27,38 @@ interface PageProps {
}
const Page: React.FC<PageProps> = ({ config }) => {
const { app } = useApp({ config });
const { app } = useApp({
config,
methods: {
refresh: () => window.location.reload()
}
});
if (!app) return null;
const MagiUiContainer = app.resolveComponent('container');
return <div
id={`${config.id || ''}`}
className={`magic-ui-page${config.className ? ` ${config.className}` : ''}`}
style={app.transformStyle(config.style || {})}
>
{config.items?.map((item: MComponent | MContainer) => {
const MagicUiComp = app.resolveComponent(item.type || 'container');
return <MagiUiContainer config={{ className: 'magic-ui-page', ...config }}></MagiUiContainer>;
if (!MagicUiComp) return null;
return (
<MagicUiComp
id={`${item.id || ''}`}
key={item.id}
config={item}
className={`magic-ui-component${config.className ? ` ${config.className}` : ''}`}
style={app.transformStyle(item.style || {})}
></MagicUiComp>
);
})}
</div>;
};
Page.displayName = 'maigc-ui-page';
Page.displayName = 'magic-ui-page';
export default Page;

View File

@@ -0,0 +1,8 @@
export default {
methods: [
{
label: '刷新页面',
value: 'refresh',
},
],
};

View File

@@ -20,5 +20,6 @@ import Page from './Page';
export { default as config } from './formConfig';
export { default as value } from './initValue';
export { default as event } from './event';
export default Page;