import { Tabs } from 'antd' import type { TabsProps } from 'antd' import { CloseOutlined } from '@ant-design/icons' import { useNavigate } from 'react-router-dom' import { useTabStore } from '../stores/tabStore' function TabBar() { const { tabs, activeKey, setActiveTab, closeTab } = useTabStore() const navigate = useNavigate() const handleChange = (key: string) => { setActiveTab(key) navigate(key) } const items: TabsProps['items'] = tabs.map((tab) => ({ key: tab.key, label: ( {tab.icon && {tab.icon}} {tab.title} ), closeIcon: tab.closable ? : false, })) return (
{ if (action === 'remove') { closeTab(key as string) navigate(useTabStore.getState().activeKey) } }} items={items} style={{ marginBottom: 0 }} tabBarStyle={{ margin: 0, border: 'none' }} />
) } export default TabBar