Browse Source

fix:close other tabs

dev
powersir 11 months ago
parent
commit
7ef5f99f82
2 changed files with 2 additions and 2 deletions
  1. +1
    -0
      src/hooks/use-tabs/index.tsx
  2. +1
    -2
      src/layout/tabs-layout.tsx

+ 1
- 0
src/hooks/use-tabs/index.tsx View File

@@ -46,6 +46,7 @@ export function useTabs() {
// 关闭除了自己其它tab // 关闭除了自己其它tab
const closeOtherTab = useCallback((routePath: string = activeTabRoutePath) => { const closeOtherTab = useCallback((routePath: string = activeTabRoutePath) => {
setKeepAliveTabs(prev => prev.filter(o => o.routePath === routePath)); setKeepAliveTabs(prev => prev.filter(o => o.routePath === routePath));
router.navigate(routePath);
}, [activeTabRoutePath]); }, [activeTabRoutePath]);


// 刷新tab // 刷新tab


+ 1
- 2
src/layout/tabs-layout.tsx View File

@@ -38,7 +38,6 @@ const TabsLayout: React.FC = () => {
].filter(o => o !== null) as MenuItemType[], ].filter(o => o !== null) as MenuItemType[],
[tabs] [tabs]
); );

const menuClick = useCallback(({ key, domEvent }: any, tab: KeepAliveTab) => { const menuClick = useCallback(({ key, domEvent }: any, tab: KeepAliveTab) => {
domEvent.stopPropagation(); domEvent.stopPropagation();


@@ -55,7 +54,7 @@ const TabsLayout: React.FC = () => {
return ( return (
<Dropdown <Dropdown
menu={{ items: menuItems, onClick: (e) => menuClick(e, tab) }} menu={{ items: menuItems, onClick: (e) => menuClick(e, tab) }}
trigger={['contextMenu']}
trigger={['hover']}
> >
<div style={{ margin: '-12px 0', padding: '12px 0' }}> <div style={{ margin: '-12px 0', padding: '12px 0' }}>
{getIcon(tab.icon)} {getIcon(tab.icon)}


Loading…
Cancel
Save