Skip to content

Commit b6ff644

Browse files
committed
fix(tabs): only render dropdown for current route
1 parent f2d9752 commit b6ff644

1 file changed

Lines changed: 25 additions & 23 deletions

File tree

src/layouts/index.tsx

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import LayoutContent from './components/Content.vue';
1111
import Setting from './setting.vue';
1212

1313
import { prefix } from '@/config/global';
14+
import { TRouterInfo } from '@/interface';
1415

1516
import '@/style/layout.less';
1617

@@ -161,7 +162,7 @@ export default defineComponent({
161162
style={{ maxWidth: '100%', position: 'fixed', overflow: 'visible' }}
162163
onRemove={handleRemove}
163164
>
164-
{tabRouters.map((router: any, idx: number) => (
165+
{tabRouters.map((router: TRouterInfo, idx: number) => (
165166
<t-tab-panel
166167
value={router.path}
167168
key={`${router.path}_${idx}`}
@@ -171,30 +172,31 @@ export default defineComponent({
171172
minColumnWidth={128}
172173
popupProps={{ overlayClassName: 'router-tabs-dropdown' }}
173174
v-slots={{
174-
dropdown: () => (
175-
<t-dropdown-menu>
176-
<t-dropdown-item onClick={() => handleRefresh(router.path, idx)}>
177-
<t-icon name="refresh" />
178-
刷新
179-
</t-dropdown-item>
180-
{idx > 0 && (
181-
<t-dropdown-item onClick={() => handleCloseAhead(router.path, idx)}>
182-
<t-icon name="arrow-left" />
183-
关闭左侧
175+
dropdown: () =>
176+
router.path === route.path ? (
177+
<t-dropdown-menu>
178+
<t-dropdown-item onClick={() => handleRefresh(router.path, idx)}>
179+
<t-icon name="refresh" />
180+
刷新
184181
</t-dropdown-item>
185-
)}
186-
{idx < tabRouters.length - 1 && (
187-
<t-dropdown-item onClick={() => handleCloseBehind(router.path, idx)}>
188-
<t-icon name="arrow-right" />
189-
关闭右侧
182+
{idx > 0 && (
183+
<t-dropdown-item onClick={() => handleCloseAhead(router.path, idx)}>
184+
<t-icon name="arrow-left" />
185+
关闭左侧
186+
</t-dropdown-item>
187+
)}
188+
{idx < tabRouters.length - 1 && (
189+
<t-dropdown-item onClick={() => handleCloseBehind(router.path, idx)}>
190+
<t-icon name="arrow-right" />
191+
关闭右侧
192+
</t-dropdown-item>
193+
)}
194+
<t-dropdown-item onClick={() => handleCloseOther(router.path, idx)}>
195+
<t-icon name="close-circle" />
196+
关闭其它
190197
</t-dropdown-item>
191-
)}
192-
<t-dropdown-item onClick={() => handleCloseOther(router.path, idx)}>
193-
<t-icon name="close-circle" />
194-
关闭其它
195-
</t-dropdown-item>
196-
</t-dropdown-menu>
197-
),
198+
</t-dropdown-menu>
199+
) : null,
198200
}}
199201
>
200202
{!router.isHome ? router.title : <t-icon name="home" />}

0 commit comments

Comments
 (0)