feat: add 'maxNumOfOpenTab' to limit the maximum number of tabs with the same name

This commit is contained in:
vben
2024-07-20 11:14:32 +08:00
parent bcd5e49117
commit 480580f104
10 changed files with 92 additions and 3 deletions

View File

@@ -28,6 +28,11 @@ function openTab() {
router.push({ name: 'VbenAbout' });
}
function openTabWithParams(id: number) {
// 这里就是路由跳转也可以用path
router.push({ name: 'FeatureTabDetailDemo', params: { id } });
}
function reset() {
newTabTitle.value = '';
resetTabTitle();
@@ -92,5 +97,19 @@ function reset() {
<Button @click="reset"> 重置 </Button>
</div>
</div>
<div class="card-box mt-5 p-5">
<div class="text-lg font-semibold">最大打开数量</div>
<div class="text-foreground/80 my-3">
限制带参数的tab打开的最大数量 `route.meta.maxNumOfOpenTab` 控制
</div>
<div class="flex flex-wrap items-center gap-3">
<template v-for="item in 5" :key="item">
<Button type="primary" @click="openTabWithParams(item)">
打开{{ item }}详情页
</Button>
</template>
</div>
</div>
</div>
</template>