From 034881e72efa03b0973aac29219a6b6f15308e04 Mon Sep 17 00:00:00 2001 From: Gary Fu Date: Mon, 1 Jan 2024 20:55:46 +0800 Subject: [PATCH] =?UTF-8?q?tabs=E6=93=8D=E4=BD=9C=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common-form/index.vue | 2 +- src/components/common-tabs-view/index.vue | 29 +++++++-- .../common-tabs-view/tabs-view-item.vue | 64 ++++++++++++++++--- src/messages/common_cn.js | 5 ++ src/messages/common_en.js | 5 ++ src/stores/TabsViewStore.js | 58 +++++++++++++++-- .../components/global/GlobalSettings.vue | 6 +- 7 files changed, 146 insertions(+), 23 deletions(-) diff --git a/src/components/common-form/index.vue b/src/components/common-form/index.vue index cc008a9..501cac4 100644 --- a/src/components/common-form/index.vue +++ b/src/components/common-form/index.vue @@ -77,7 +77,7 @@ const rules = computed(() => { return ruleResult }) -const form = ref(null) +const form = ref() diff --git a/src/components/common-tabs-view/index.vue b/src/components/common-tabs-view/index.vue index 1e77a34..c09f062 100644 --- a/src/components/common-tabs-view/index.vue +++ b/src/components/common-tabs-view/index.vue @@ -8,11 +8,10 @@ import TabsViewItem from '@/components/common-tabs-view/tabs-view-item.vue' const router = useRouter() const route = useRoute() const tabsViewStore = useTabsViewStore() -const currentTabValue = ref('') watch(route, () => { if (route.path) { tabsViewStore.addHistoryTab(route) - currentTabValue.value = route.path + tabsViewStore.currentTab = route.path } }) @@ -20,13 +19,14 @@ onMounted(() => { if (!tabsViewStore.historyTabs.length) { tabsViewStore.addHistoryTab(route) } - currentTabValue.value = route.path + tabsViewStore.currentTab = route.path }) const selectHistoryTab = path => { const tab = isString(path) ? tabsViewStore.findHistoryTab(path) : path if (tab) { router.push(tab) + tabsViewStore.addCachedTab(tab) } } @@ -40,6 +40,7 @@ const removeHistoryTab = path => { const refreshHistoryTab = tab => { const time = new Date().getTime() router.push(`${tab.path}?${time}`) + tabsViewStore.addCachedTab(tab) } const removeOtherHistoryTabs = tab => { @@ -47,12 +48,29 @@ const removeOtherHistoryTabs = tab => { selectHistoryTab(tab.path) } +const removeHistoryTabs = (tab, type) => { + tabsViewStore.removeHistoryTabs(tab, type) + selectHistoryTab(tab.path) +} + +const tabItems = ref() +const onDropdownVisibleChange = (visible, tab) => { + if (visible) { + tabItems.value.forEach(({ dropdownRef }) => { + console.info(Object.assign({}, dropdownRef)) + if (dropdownRef.id !== tab.path) { + dropdownRef.handleClose() + } + }) + } +} +