From b6ff64440c0b2d1dd4ee349953d8b5e955d17646 Mon Sep 17 00:00:00 2001 From: Uyarn Date: Fri, 25 Mar 2022 01:05:01 +0800 Subject: [PATCH] fix(tabs): only render dropdown for current route --- src/layouts/index.tsx | 48 ++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/layouts/index.tsx b/src/layouts/index.tsx index 1feebef..610dbaf 100644 --- a/src/layouts/index.tsx +++ b/src/layouts/index.tsx @@ -11,6 +11,7 @@ import LayoutContent from './components/Content.vue'; import Setting from './setting.vue'; import { prefix } from '@/config/global'; +import { TRouterInfo } from '@/interface'; import '@/style/layout.less'; @@ -161,7 +162,7 @@ export default defineComponent({ style={{ maxWidth: '100%', position: 'fixed', overflow: 'visible' }} onRemove={handleRemove} > - {tabRouters.map((router: any, idx: number) => ( + {tabRouters.map((router: TRouterInfo, idx: number) => ( ( - - handleRefresh(router.path, idx)}> - - 刷新 - - {idx > 0 && ( - handleCloseAhead(router.path, idx)}> - - 关闭左侧 + dropdown: () => + router.path === route.path ? ( + + handleRefresh(router.path, idx)}> + + 刷新 - )} - {idx < tabRouters.length - 1 && ( - handleCloseBehind(router.path, idx)}> - - 关闭右侧 + {idx > 0 && ( + handleCloseAhead(router.path, idx)}> + + 关闭左侧 + + )} + {idx < tabRouters.length - 1 && ( + handleCloseBehind(router.path, idx)}> + + 关闭右侧 + + )} + handleCloseOther(router.path, idx)}> + + 关闭其它 - )} - handleCloseOther(router.path, idx)}> - - 关闭其它 - - - ), + + ) : null, }} > {!router.isHome ? router.title : }