import React, { createContext, useContext } from 'react'; import { Menu, Space, Tooltip } from 'antd'; import { SettingOutlined, MoreOutlined, DesktopOutlined } from '@ant-design/icons'; import { CurrentUser, DesignableSwitch, CollectionManagerAction, ACLAction, SystemSettings } from '../'; import { get } from 'lodash'; import { PluginManagerContext, PluginManagerProvider } from '.'; // TODO export const PluginManager: any = () => null; PluginManager.Provider = PluginManagerProvider; const ToolbarItemContext = createContext(null); PluginManager.Toolbar = (props: any) => { const { components } = useContext(PluginManagerContext); const { items = [] } = props; return (
{items .filter((item) => item.pin) .map((item) => { const Action = get(components, item.component); return ( Action && ( ) ); })} }> {items .filter((item) => !item.pin) .map((item) => { const Action = get(components, item.component); return ( Action && ( ) ); })} }>管理插件
); }; PluginManager.Toolbar.Item = (props) => { const item = useContext(ToolbarItemContext); const { icon, title, ...others } = props; if (item.pin) { return ( {icon} ); } return ( {title} ); };