diff --git a/src/store/modules/tab/index.ts b/src/store/modules/tab/index.ts index f590f3de..2c9b8bbc 100644 --- a/src/store/modules/tab/index.ts +++ b/src/store/modules/tab/index.ts @@ -1,3 +1,5 @@ +import { unref } from 'vue'; +import type { Ref } from 'vue'; import type { Router, RouteLocationNormalizedLoaded } from 'vue-router'; import { defineStore } from 'pinia'; import { useRouterPush } from '@/composables'; @@ -50,6 +52,16 @@ export const useTabStore = defineStore('tab-store', { setActiveTab(fullPath: string) { this.activeTab = fullPath; }, + /** + * 设置当前路由对应的页签title + * @param title - tab名称 + */ + setActiveTabTitle(title: string | Ref) { + const item = this.tabs.find(tab => tab.fullPath === this.activeTab); + if (item) { + Object.assign(item, { meta: { title: unref(title) } }); + } + }, /** * 初始化首页页签路由 * @param routeHomeName - 路由首页的name diff --git a/src/views/function/tab/index.vue b/src/views/function/tab/index.vue index cafdeb65..6bd81a15 100644 --- a/src/views/function/tab/index.vue +++ b/src/views/function/tab/index.vue @@ -5,16 +5,24 @@ 跳转Tab Detail 跳转Tab Multi Detail 1 跳转Tab Multi Detail 2 + + + 设置当前Tab页标题 +