fix(ui): 页面组件无法支持event配置
This commit is contained in:
@@ -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;
|
||||
|
||||
8
packages/ui-react/src/page/event.ts
Normal file
8
packages/ui-react/src/page/event.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export default {
|
||||
methods: [
|
||||
{
|
||||
label: '刷新页面',
|
||||
value: 'refresh',
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user