feat(projects): 增加设置当前Tab页签名称功能

This commit is contained in:
燕博文
2022-06-14 15:42:59 +08:00
parent 4ee0d94f1b
commit 487213b648
2 changed files with 28 additions and 0 deletions

View File

@ -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<string>) {
const item = this.tabs.find(tab => tab.fullPath === this.activeTab);
if (item) {
Object.assign(item, { meta: { title: unref(title) } });
}
},
/**
* 初始化首页页签路由
* @param routeHomeName - 路由首页的name