import { useState } from 'react'; import { Tabs } from 'antd'; import { PluginPageSchema, PluginEntitySchema, PluginFieldSchema, } from '../api/plugins'; interface PluginTabsPageProps { pluginId: string; label: string; icon?: string; tabs: PluginPageSchema[]; entities: PluginEntitySchema[]; } export function PluginTabsPage({ pluginId, label, tabs, entities }: PluginTabsPageProps) { const [activeKey, setActiveKey] = useState(tabs[0] && 'label' in tabs[0] ? tabs[0].label : ''); const renderTabContent = (tab: PluginPageSchema) => { if (tab.type === 'crud') { // 懒加载 PluginCRUDPage 避免循环依赖 const PluginCRUDPage = require('./PluginCRUDPage').default; return ( ); } if (tab.type === 'tree') { const PluginTreePage = require('./PluginTreePage').PluginTreePage; const entity = entities.find((e) => e.name === tab.entity); return ( ); } return
不支持的页面类型: {tab.type}
; }; const items = tabs.map((tab) => ({ key: 'label' in tab ? tab.label : '', label: 'label' in tab ? tab.label : '', children: renderTabContent(tab), })); return (
); }