feat: configurable persistent tabs

This commit is contained in:
vince
2024-07-10 00:50:41 +08:00
parent 41d0495630
commit db76325d68
23 changed files with 177 additions and 176 deletions

View File

@@ -1,4 +1,8 @@
<script lang="ts" setup>
import { useRoute } from 'vue-router';
import { preferences } from '@vben-core/preferences';
import { useCoreTabbarStore } from '@vben-core/stores';
import { TabsView } from '@vben-core/tabs-ui';
import { useTabs } from './use-tabs';
@@ -9,14 +13,23 @@ defineOptions({
defineProps<{ showIcon?: boolean }>();
const route = useRoute();
const coreTabbarStore = useCoreTabbarStore();
const {
createContextMenus,
currentActive,
currentTabs,
handleClick,
handleClose,
handleUnPushPin,
handleUnpinTab,
} = useTabs();
// 刷新后如果不保持tab状态关闭其他tab
if (!preferences.tabbar.persist) {
coreTabbarStore.closeOtherTabs(route);
}
</script>
<template>
@@ -26,7 +39,7 @@ const {
:show-icon="showIcon"
:tabs="currentTabs"
@close="handleClose"
@un-push-pin="handleUnPushPin"
@unpin-tab="handleUnpinTab"
@update:active="handleClick"
/>
</template>